我有這樣一個Python中的圖表:如何使用Python在(交互式)3D中可視化圖形?
# Each element is a tuple with coordinates (x,y,z).
# The index is the id of the vertex
vertexList = [(0,0,0),(1,0,0),(1,1,0),(0,1,0),
(0,0,1),(1,0,1),(1,1,1),(0,1,1)]
# Each element is a tuple with the vertex-ids and a weight (vertexId1, vertexId2, weight)
edgeList = [(0,1,1), (1,2,1), (2,3,1), (3,0,1),
(0,4,1),
(4,5,1), (5,6,1), (6,7,1), (7,4,1)]
graph = (vertexList, edgeList)
這是一個小例子。我編寫的應用程序使用包含約100個頂點和300個邊的圖。
我想用python想象這個,最好有一個可用於Ubuntu的庫。如果可以在3D可視化中移動圖表,那將會很棒。
我到目前爲止已經
做在我使用UBIGRAPH的時刻。可視化和互動是非常好的,但我不能爲頂點指定座標:
def visulizeGraph(Graph):
vertexList, edgeList = Graph
server_url = 'http://127.0.0.1:20738/RPC2'
server = xmlrpclib.Server(server_url)
G = server.ubigraph;
G.clear()
for identifier, vertex in enumerate(vertexList):
G.new_vertex_w_id(identifier)
for vertex1, vertex2, weight in edgeList:
x1, y1, z1 = vertexList[vertex1]
x2, y2, z2 = vertexList[vertex2]
G.new_edge(vertex1, vertex2)
matplot
我發現matplotlib,但它非常大。我沒有找到一個符合我喜歡的例子,但我可能錯過了它。它可用於Ubuntu。
VTK
同樣的問題與matplot。如果你能給我一些實例,那可能是最好的解決方案。
我不禁想到,名稱「Mayavi」可能會成爲商標侵權的挑戰,Maya 3D軟件包的內容如何。或者說,它不是一個問題就足夠大了? – JAB