我try 创建一种水平条形图叠加在现有的matplotlib图.我想要一个传奇的wine 吧.
下面是一个例子
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
y_data = (0,0,1,0)
ax.step((0., 0.1, 0.2, 0.6, 0.8, 1.), (0., 0., 0.5, 1., 0.5, 0.), where='pre')
ax.plot((0.1,0.6),(0.1,0.1), color = 'red', linewidth = 10, label = "line 1")
ax.plot((0.2,0.8),(0.2,0.2), color = 'green', linewidth = 10, label = "line 2")
ax.set_ylim(0,1); ax.set_xlim(0,1)
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
plt.tight_layout()
直线段开始于直线端点的坐标之前一点,结束于直线端点的坐标之后一点.该量似乎取决于线的粗细.如何消除开头和结尾的多余? 我想画矩形,但是我怎么画图例呢?