1
我有一个每个数据集只有一个数据点(即一个错误条)的错误条图。因此,我想在图例中也有一个错误栏符号。 单一可以通过legend(numpoints=1)
来实现。在这些符号在图例errorbar,但不行,作为python matplotlib图例中的标记符号
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.errorbar(x=[0.3], y=[0.7], xerr=[0.2], marker='+', markersize=10, label='horizontal marker line')
ax.errorbar(x=[0.7], y=[0.3], yerr=[0.2], marker='+', markersize=10, label='is too long')
ax.set_xlim([0,1])
ax.set_ylim([0,1])
ax.legend(numpoints=1) # I want only one symbol
plt.show()
正如你看到的,errorbars混合了水平线条,使感觉,当有一个以上连接错误条(使用legend(numpoints=2)
或更高版本),但在我的情况下看起来很丑。
如何在不丢失错误条的情况下摆脱图例标记中的行?
下面的答案是否解决了您的问题?如果是的话,接受它,否则评论你有什么问题。 – DavidG