我可以使用plot函数绘制一个图形。 但我想通过在轴上绘制投影并在点和轴上放置文本来强调一些“特殊”点
我试过这个:
import matplotlib.pyplot as plt
[...]
plt.plot(X, Y, label='data') # draw curve, X and Y are arrays
plt.plot(Xp, Yp, c, duration), marker='o') # draw point @(Xp, Yp), Xp and Yp are scalars
plt.vlines(Xp, min(Y), Yp, linestyles='dashed')
plt.hlines(Yp, min(X), Xp, linestyles='dashed')
plt.grid(True)
plt.show()
但我得到的并不令人满意:
获得我想要的东西的正确方法是什么?
我也考虑过annotate
,但它似乎不能满足我的需要。如果我错了,请纠正我
像这样的东西可能就是你正在寻找的答案https://stackoverflow.com/a/14434334/14920085
您可以将
annotate
与blended transformation一起使用:这并不完美,因为您可能仍然需要手动调整轴坐标(例如
-0.05
而不是0
),以将标签设置得稍微偏离轴你需要玩一下
xlim
和ylim
对我来说,这很有效:
相关问题 更多 >
编程相关推荐