我有我與Python的matplotlib的幫助下繪製的數據集如下:Matplotlib設置欄的起點值
import matplotlib.pyplot as plt
%matplotlib inline
n_groups = 10
fig, ax = plt.subplots()
fig.set_size_inches(15,10)
index = np.arange(0, n_groups * 2, 2)
print index
bar_width = 0.35
opacity = 0.4
error_config = {'ecolor': '0.3'}
rects1 = plt.bar(index, df.Quant[0:10], bar_width,
alpha=opacity,
color='b',
error_kw=error_config,
label='Quant')
rects2 = plt.bar(index + bar_width, df.English[0:10], bar_width,
alpha=opacity,
color='r',
error_kw=error_config,
label='English')
rects3 = plt.bar(index + bar_width * 2, df.Logical[0:10], bar_width,
alpha=opacity,
color='g',
error_kw=error_config,
label='Logical')
plt.xlabel('Group')
plt.ylabel('Scores')
plt.title('Scores by Designation')
plt.xticks(index + bar_width, df.Designation[0:10], rotation='vertical')
plt.legend()
plt.tight_layout()
plt.show()
導致進入如下圖:
由於你可以看到,這些值在400點以上是不同的。我如何將圖表的範圍從400縮小到更大?
此外,我試圖在seaborn
中做同樣的事情,但找不到任何示例。
我對「縮小圖表範圍」的含義有些困惑。你在問如何改變y-限制嗎? (如果是這樣,請參閱'plt.ylim'或'ax.set(ylim = [ymin,ymax])')您可能還會考慮'plt.margins(x = 0.05)'將數據範圍。 –
@JoeKington太棒了,是啊,那正是我想要的'ax.set'。請原諒我可憐的選詞:P –