を使用してこれを行いmatplotilb
ます。これは最小限のコードです。NaN
ポイントの個々のプロットや不連続な線でゲームをするのではなく、散布図でこれを行う方が効率的かもしれませんが、これはうまくいきます. 楕円の例 については、こちらを参照してください。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)