抱歉,我无法发布我的真实数据或绘图。。所以我用MS画作了象形图
所以我有我的图-橙色线,作为一组X和Y值plt.plot(data_x, data_y)
给出。
然后我添加了水平线-蓝线:plt.axvline(x=10)
。
现在我想用这条线和我的图之间的颜色空间填充(最终,当值低于水平线时,用一种颜色填充,当值高于水平线时,用第二种颜色填充)
我尝试了plt.fill
和plt.fill_between
和plt.axhspan
但是,我收到了关于维度问题或元素与序列的错误
有没有一个简单的方法可以做到这一点
Tags:
你必须使用
请注意,数据_y2必须是标量(例如0)或与数据_y具有相同形状
您可以在此处找到相关文档:
https://matplotlib.org/3.1.1/gallery/lines_bars_and_markers/fill_between_demo.html
及
https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.fill_between.html
是的,有一个} 用于执行此操作:
where
参数^{相关问题 更多 >
编程相关推荐