繁体   English   中英

如何使用Matplotlib在图的中间绘制轴

[英]How to draw an axis in the middle of the figure using Matplotlib

我想画一条平行于y轴且在x轴中间的静态垂直线。 当图中的一个平移时,此行不应移动。 我的目标是使图中间的垂直线作为参考线。 我将有一些其他的数字表示数据,这些数据将取决于x轴中间的x值。

该行端点的坐标在轴坐标中为(0.5,0)和(0.5,1):

from matplotlib.lines import Line2D
from matplotlib import pyplot

f=pyplot.figure()
a=f.add_subplot(111)
a.plot([3,1,4,1,5,9,2], color='k') # so you have some content
a.add_line(Line2D([0.5, 0.5], [0, 1], transform=a.transAxes,
                  linewidth=2, color='b'))
pyplot.show()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM