我有这样一个情节:
我使用annotate方法绘制这些箭头
ax.annotate('sample events', (x_value, y_value), xytext=(x_value, -3000), rotation=90, va='top', arrowprops = {'width': 2, 'headwidth': 4, 'linestyle': '--'})
但我想要的是:
如果注释文本在x轴上会更好,有什么办法吗
(我试过ax.axvline(x=x_值),但它会在整个绘图中形成垂直线)
Tags:
简单的方法是使用
ax.stem
,例如:生成的示例图为:
如果要隐藏水平线,请使用
basefmt = " "
:首先:您应该避免代码中的
#
,因为它将被解释为comment根据
ax.annotate
的documentation,您应该轻松地将线型指定为虚线,以及标签的位置可以在here找到一个很好的示例列表。您应该尝试类似的方法:
ax.annotate('dashed line', xy=(0.25,0.2), xytext=(0.6,0.2),arrowprops={'arrowstyle': '-', 'ls': 'dashed'}, va='center', rotate=90)
相关问题 更多 >
编程相关推荐