2017-04-22 72 views
1

我有如下情節:如何設置X軸限多年在matplotlib圖

%matplotlib inline 
import matplotlib.pyplot as plt 

df[['Year','Unemployment with primary education (% of total 
unemployment)','Unemployment with secondary education (% of total 
unemployment)','Unemployment with tertiary education (% of total 
unemployment)']].set_index('Year').plot() 

plt.legend(loc='center left', bbox_to_anchor=(1, 0.5)) 

enter image description here

我想限制x軸高達2005只。我怎樣才能做到這一點?

回答

1

我沒有你的數據,但如果'year'是一個簡單的數字,你可以通過調用

plt.xlim(None, 2005) 
設置的限制