python - Matplotlib: Can a plot a line from one set of axes to another? -
i wish plot marker "x" @ [100,100] , plot "o" @ [20%, 30%] (different axes, same plot) , connect them line. can similar on same axes (with same units) 1 call plot line, call plot "x" , final call plot "o".
ax.plot(x,y,"-") ax.scatter(x[0], y[0], marker='x') ax.scatter(x[1], y[1], marker='o') however, how can line go 1 set of axes other?
you can use annotate draw single lines:
ax1 = plt.subplot(121) ax2 = plt.subplot(122) x = [[1, 2], [3,4]] y = [[5, 6], [6,4]] ax1.scatter(x[0], y[0]) ax2.scatter(x[1], y[1]) ax1.annotate('', xy=(x[0][0], y[0][0]), xytext=(x[1][0], y[1][0]), xycoords=ax1.transdata, textcoords=ax2.transdata, arrowprops=dict(facecolor='black', arrowstyle='-',, clip_on=false)) ax2.annotate('', xy=(x[0][0], y[0][0]), xytext=(x[1][0], y[1][0]), xycoords=ax1.transdata, textcoords=ax2.transdata, arrowprops=dict(facecolor='black', arrowstyle='-')) which produces result:

Comments
Post a Comment