简体   繁体   English

如何在 Python 中使用 Matplotlib 将条停靠到边界框的底部?

[英]How to dock bars to the bottom of the bounding box with Matplotlib in Python?

I'm drawing a Barplot in Python with matplotlib, and currently it looks as follows.我正在用 matplotlib 在 Python 中绘制条形图,目前它看起来如下。

在此处输入图像描述

Briefly, I'm measuring a quantity called EOD under different settings (represented with different colors), and plotting the mean and std.简而言之,我在不同的设置(用不同的颜色表示)下测量一个称为 EOD 的量,并绘制平均值和标准差。 dev.开发。 values for each setting over multiple measurements I've done.我已经完成的多次测量中每个设置的值。

The problem is, this EOD quantity can strictly take non-negative values so the area under 0 is misleading.问题是,这个 EOD 数量可以严格取非负值,因此 0 以下的区域具有误导性。 I know this happens because for some settings (for example the blue one) the std.我知道会发生这种情况,因为对于某些设置(例如蓝色设置),std. dev is larger than mean value. dev 大于平均值。 Still, I'd like to prevent this.不过,我想防止这种情况发生。

In short, how can I dock my bars to the bottom of the bounding box where it should start from 0?简而言之,我怎样才能将我的条停靠在边界框的底部,它应该从 0 开始?

ax.set_ylim(ymin=0)

did the trick as suggested by JohanC in the comments.做了JohanC在评论中建议的伎俩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM