python /matplotlib : create graph with changing background colors

标签 python matplotlib

我想要一张根据某些变量改变背景颜色的图表,例如:enter image description here

我的变量将确定特定 X 值的背景是灰色、红色还是绿色。我知道 set_facecolor(color),但这只会改变整个背景。

最佳答案

您可以使用fill_between()填充 x 轴之间的区域。这是demo如何使用 x 轴做到这一点

关于 python /matplotlib : create graph with changing background colors,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54977900/

相关文章:

python - 如何将散点图中的点显示为加号和减号?

python - matplotlib:为条形分配不同的影线

python - 如何使用SQS(亚马逊简单队列服务)实现优先级队列

python - 在 Vagrant 中运行 Python 脚本

python - pyspark 数据框中所有列的总计数为零

python - Django : Escaping Html in Django Admin field?

python - 通过Python解析文件

python - 重置 matplotlib 子图中的默认轴刻度

python - matplotlib 中具有重叠点的散点图的可视化

python - PyCharm + Matplotlib?