[英]Pandas Time Series Plot: Secondary y-Axis Label , Set Lower Limit
[英]Why can't I set the y-axis range on a plot produced from a Pandas Series?
我正在尝试使用matplotlib和pandas创建条形图,其中y轴的范围为0%-100%。 我得到的范围仅为0%-50%。 现在,由于我所有的酒吧都达到了10%的最高点,所以这并不是灾难性的。 这只是令人沮丧,并且可能会干扰与完整范围内其他图的比较。
我使用的代码大致如下:
from matplotlib import pyplot as plt
import pandas as pd
labels = list(cm.index) #Where cm is a DataFrame
for curr in sorted(labels):
xa = cm[curr] # Pulls 1 column out of DataFrame to be plotted
xplt = xa.plot(kind='bar', rot = 0, ylim = (0,1))
xplt.set_yticklabels(['{:3.0f}%'.format(x*10) for x in range(11)])
plt.show()
有什么明显的错误或遗漏吗?
我得到的情节样本是这样的:
奇怪的是,当我省略set_yticklabels语句时,我得到了:
我现在意识到,第一个图形不仅按比例缩放,而且给出的结果也不正确。 第二张图中显示的值是正确的值。 我猜错误是在set_yticklabels语句中,但我不知道它可能是什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.