[英]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.