我使用注释方法绘制那些箭头
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_value),但它在整个图上都形成了垂直线)
答案 0 :(得分:1)
简单的方法是使用function addboldtext() {
const doc=DocumentApp.getActiveDocument();
const body=doc.getBody();
const style1={};
style1[DocumentApp.Attribute.BOLD]=true;
style1[DocumentApp.Attribute.FOREGROUND_COLOR]='#000000';//you can add all of the attributes that you wish
body.appendParagraph("This is text").setAttributes(style1)
}
,例如:
ax.stem
结果示例图为:
如果要隐藏水平线,请使用import matplotlib.pyplot as plt
import numpy as np
y = np.random.random(20)
fig, ax = plt.subplots()
ax.plot(y)
ax.stem(y, markerfmt='.')
plt.show()
:
basefmt = " "
答案 1 :(得分:0)
首先:您应避免在代码中使用#
,因为它将被解释为comment。
根据ax.annotate
的{{3}},您应轻松指定虚线的线型以及标签位置。 可以找到很好的示例列表documentation。
您应该尝试类似的操作:ax.annotate('dashed line', xy=(0.25,0.2), xytext=(0.6,0.2),arrowprops={'arrowstyle': '-', 'ls': 'dashed'}, va='center', rotate=90)