如何制作一个不会从y = 0开始
我想在Python中制作一个具有自己的“基线”的Barchart,因此Y-AS不在0开始(通常像通常一样),而是我选择的价值。
I want to make an barchart in python that has its own 'baseline', thus that the y-as doesn't start at 0 (as it usually does) but my chosen value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将
底部
参数用于matplotlib.pyplot.bar
。可以在plt.bar
呼叫中使用,也可以在pandas.dataframe.plot.bar
中使用,该将将关键字参数传递到matplotlib。底部的参数将添加到数据框中的所有值中,因此您需要在绘制之前从数据框架的值中减去它。例如:
You can use the
bottom
argument tomatplotlib.pyplot.bar
. This can be used in aplt.bar
call or inpandas.DataFrame.plot.bar
, which will pass keyword arguments through to matplotlib. The bottom argument will be added to all values in the dataframe, so you need to subtract it from the dataframe's values prior to plotting.For example: