D3.js와 동등한 Python
대화 형 그래프 시각화를 수행 할 수있는 Python 라이브러리를 추천 할 수 있습니까 ?
나는 특별히 d3.js 와 같은 것을 원 하지만 python
이상적으로는 3D도 될 것입니다.
나는 보았다 :
- NetworkX-
Matplotlib
플롯 만 수행 하며 2D로 보입니다. 나는d3.js
노드를 끌어 당기는 것과 같은 어떤 종류의 상호 작용도 보지 못했습니다 . - 그래프 도구 -2D 플롯 만 수행하고 매우 느린 대화 형 그래프를 가지고 있습니다.
d3.js 스크립트를 포함하는 xml 페이지를 생성하는 파이썬 모듈 인 d3py를 사용할 수 있습니다 . 예 :
import d3py
import networkx as nx
import logging
logging.basicConfig(level=logging.DEBUG)
G = nx.Graph()
G.add_edge(1,2)
G.add_edge(1,3)
G.add_edge(3,2)
G.add_edge(3,4)
G.add_edge(4,2)
# use 'with' if you are writing a script and want to serve this up forever
with d3py.NetworkXFigure(G, width=500, height=500) as p:
p += d3py.ForceLayout()
p.show()
Plotly는 대화 형 2D 및 3D 그래프를 지원합니다. 그래프는 D3.js로 렌더링되며 Python API , matplotlib , Python 용 ggplot , Seaborn , prettyplotlib 및 pandas 로 생성 할 수 있습니다 . 확대 / 축소, 이동, 트레이스 켜기 / 끄기, 마우스 오버시 데이터를 볼 수 있습니다. 플롯은 HTML, 앱, 대시 보드 및 IPython 노트북에 포함될 수 있습니다. 아래는 상호 작용을 보여주는 온도 그래프 입니다. 더 많은 예제 는 IPython 노트북 튜토리얼 갤러리를 참조하십시오 .
문서는 지원 플롯 유형과 코드 조각의 예제를 제공합니다.
특히 귀하의 질문에 대해 NetworkX에서 대화 형 플롯 을 만들 수도 있습니다 .
Python을 사용한 3D 플로팅의 경우 유사하게 상호 작용하는 3D 산점, 선 및 표면 플롯을 만들 수 있습니다. 플롯은 WebGL로 렌더링됩니다. 예를 들어 영국 스왑 금리 의 3D 그래프 를 참조하십시오 .
공개 : 저는 Plotly 팀에 있습니다.
빈센트를 봤어? Vincent는 Python 데이터 개체를 가져 와서 Vega 시각화 문법으로 변환합니다. Vega는 D3 위에 구축 된 더 높은 수준의 시각화 도구입니다. D3py와 비교할 때 vincent repo가 더 최근에 업데이트되었습니다. 예제는 모두 정적 D3입니다.
더 많은 정보:
그래프는 Ipython에서 볼 수 있습니다.이 코드를 추가하면됩니다.
vincent.core.initialize_notebook()
Or output to JSON where you can view the JSON output graph in the Vega online editor (http://trifacta.github.io/vega/editor/) or view them on your Python server locally. More info on viewing can be found in the pypi link above.
Not sure when, but the Pandas package should have D3 integration at some point. http://pandas.pydata.org/developers.html
Bokeh is a Python visualization library that supports interactive visualization. Its primary output backend is HTML5 Canvas and uses client/server model.
examples: http://continuumio.github.io/bokehjs/
One recipe that I have used (described here: Co-Director Network Data Files in GEXF and JSON from OpenCorporates Data via Scraperwiki and networkx ) runs as follows:
- generate a network representation using networkx
- export the network as a JSON file
- import that JSON into to d3.js. (networkx can export both the tree and graph/network representations that d3.js can import).
The networkx JSON exporter takes the form:
from networkx.readwrite import json_graph
import json
print json.dumps(json_graph.node_link_data(G))
Alternatively you can export the network as a GEXF XML file and then import this representation into the sigma.js Javascript visualisation library.
from xml.etree.cElementTree import tostring
writer=gf.GEXFWriter(encoding='utf-8',prettyprint=True,version='1.1draft')
writer.add_graph(G)
print tostring(writer.xml)
Another option is bokeh which just went to version 0.3.
For those who recommended pyd3, it is no longer under active development and points you to vincent. vincent is also no longer under active development and recommends using altair.
So if you want a pythonic d3, use altair.
Check out python-nvd3. It is a python wrapper for nvd3. Looks cooler than d3.py and also has more chart options.
I would suggest using mpld3 which combines D3js javascript visualizations with matplotlib of python.
The installation and usage is really simple and it has some cool plugins and interactive stuffs.
Plotly can do some cool stuffs for you
Produces highly interactive graphs that can be easily embedded withing the HTML pages for your private server or website using its off line API.
Update: I am note sure about its 3D plotting capabilities, for 2D graphs is awesome Thanks
You can also choose to serialize your data and then visualize it in D3.js, as done here: Use Python & Pandas to Create a D3 Force Directed Network Diagram (It comes with a jupyter notebook as well!)
Here is the gist. You serialize your graph data in this format:
import json
json_data = {
"nodes":[
{"name":"Myriel","group":1},
{"name":"Napoleon","group":1},
{"name":"Mlle.Baptistine","group":1},
{"name":"Mme.Magloire","group":1},
{"name":"CountessdeLo","group":1},
],
"links":[
{"source":1,"target":0,"value":1},
{"source":2,"target":0,"value":8},
{"source":3,"target":0,"value":10},
{"source":3,"target":2,"value":6},
{"source":4,"target":0,"value":1},
{"source":5,"target":0,"value":1},
]
}
filename_out = 'graph_data.json'
json_out = open(filename_out,'w')
json_out.write(json_data)
json_out.close()
Then you load the data in with d3.js:
d3.json("pcap_export.json", drawGraph);
For the routine drawGraph
I refer you to the link, however.
Try https://altair-viz.github.io/ - the successor of d3py and vincent. See also
- https://altair-viz.github.io/gallery/index.html
- https://speakerdeck.com/jakevdp/bespoke-visualizations-with-a-declarative-twist
There is an interesting port of NetworkX to Javascript that might do what you want. See http://felix-kling.de/JSNetworkX/
See:
Is there a good interactive 3D graph library out there?
The accepted answer suggests the following program, which apparently has python bindings: http://ubietylab.net/ubigraph/
Edit
I'm not sure about the interactivity of NetworkX, but you can definitely make 3D graphs. There is at least one example in the gallery:
http://networkx.lanl.gov/examples/drawing/edge_colormap.html
And another example in the 'examples'. This one, however, requires that you have Mayavi.
http://networkx.lanl.gov/examples/3d_drawing/mayavi2_spring.html
Python을 사용하여 D3.js 네트워크 다이어그램을 자동으로 생성하는 좋은 예가 있습니다. http://brandonrose.org/ner2sna
멋진 점은 자동 생성 된 HTML 및 JS로 끝나고 IFrame이있는 노트북에 대화 형 D3 차트를 포함 할 수 있다는 것입니다.
참고 URL : https://stackoverflow.com/questions/12977517/python-equivalent-of-d3-js
'Programing' 카테고리의 다른 글
파이썬에서 목록 이해 또는 생성기 표현식에 대한 줄 연속 (0) | 2020.08.22 |
---|---|
include 문, 헤더 또는 소스를 어디에 넣을까요? (0) | 2020.08.22 |
Docker 컨테이너를 사용하는 DC / OS의 Marathon vs Kubernetes vs Docker Swarm (0) | 2020.08.22 |
Postgres : "오류 : 캐시 된 계획은 결과 유형을 변경하면 안됩니다." (0) | 2020.08.22 |
장식 된 기능의 서명 보존 (0) | 2020.08.21 |