matplotlib图例显示双错误栏

use*_*424 6 python matplotlib

为什么matplotlib显示两个错误栏?我认为它可能与非对称误差条有关.

在此输入图像描述

你可以用这个重现问题:

>>> import matplotlib.pyplot as plt
>>> plt.errorbar([1,2,3],[3,4,2],yerr=[[1,2,0.5]]*2, label='data')
<Container object of 3 artists>
>>> plt.legend()
<matplotlib.legend.Legend object at 0x10b82f590>
>>> plt.show()
Run Code Online (Sandbox Code Playgroud)

HYR*_*YRY 13

您可以设置图例中的点数:

plt.legend(numpoints=1)
Run Code Online (Sandbox Code Playgroud)