내가 matplotilb
를 사용하여이 작업을 수행 할 것입니다 감사합니다. 이것은 최소한의 코드입니다. 불연속 라인에 대해서는 점을위한 개별 플롯 대신에 산산이로 이것을 수행하고 NaN
으로 게임을하는 것이 더 효율적일 수 있습니다. 그러나 이것은 효과적입니다. 타원 예제는 here을 참조하십시오. text
documentation 또는 애호가가되고 싶다면 doc.
import matplotlib.pyplot as plt
import numpy as np
def plot_level(ax,t,location_map, link_pairs,shift_scale = 10):
# add some code that adds the ellipse + time label
shift = np.array([0,t*shift_scale])
# plot nodes + labels
for key in location_map:
pt_location = location_map[key] + shift
ax.plot(pt_location[0],pt_location[1],'ok')
ax.text(pt_location[0],pt_location[1],key + "%d"%t) # play with this to make it look good
# plot connections
for a,b in link_pairs:
ax.plot(*(np.vstack((location_map[a],location_map[b])) + shift.T).T,color='k')
plt.draw()
location_map = {}
location_map['A'] = np.array([0,0])
location_map['B'] = np.array([1,1])
location_map['C'] = np.array([2,0])
location_map['D'] = np.array([3,1])
link_pairs1 = [('A','B')]
link_pairs2 = [('B','C')]
fig = plt.figure()
ax = plt.gca()
ax.yaxis.set_visible(False)
ax.xaxis.set_visible(False)
# function_that_draws_axes_marker
plot_level(gca(),0,location_map,[])
plot_level(gca(),1,location_map,link_pairs1)
plot_level(gca(),2,location_map,link_pairs2)
# function_that_draws_vertical_lines(t_range,location_map,shift_scale=10)
Space Time 그래프의 의미를 보여줄 수 있습니까? 그 구문에 대한 나의 해석은 당신이 원하는 것이 아닌 것으로 의심되는 상대성 이론을 포함합니다 (http://en.wikipedia.org/wiki/Minkowski_diagram). – tacaswell
이 이미지 http://imageshack.us/a/img521/9890/spacetimegraph.png와 같은 것을 갖고 싶습니다. 시간 = 0에서 노드 B, C 및 D가 연결되고 A가 단독입니다. 시간 = 10에서 노드 A와 B가 연결됩니다. 또한 C와 D가 연결됩니다. 등등 .... – OSMuser
이 질문에 대한 답변을 수락해야합니다. – tacaswell