matplotlib上的Fit X标度[关闭]

问题描述 投票:0回答:1
gdp = web.DataReader('GDP', 'fred', start)
unemploy = web.DataReader('UNRATE', 'fred', start)

fig,ax1 = plt.subplots()
fig = plt.figure(figsize=(100,50))
fig.autofmt_xdate()
color = 'tab:green'

ax1.set_xlabel('Date')
ax1.set_ylabel('Billions of Dollars', color=color)
ax1.plot(gdp, color=color)
ax1.tick_params(axis='y', labelcolor=color)

ax2 = ax1.twinx() 

color1 = 'tab:blue' 
ax2.set_ylabel('Percent', color=color1)
ax2.plot(unemploy, color=color1)
ax2.tick_params(axis='y', labelcolor=color1)

fig.tight_layout() 
plt.show();

Plot of GDP and Unemployment of USA

我正在尝试更改x轴以适合绘图。我尝试了缩放功能。

python matplotlib plot plotly matplotlib-basemap
1个回答
0
投票

您可以尝试旋转x轴标签:

plt.xticks(rotation=45)

或减小刻度的字体大小:

plt.xticks(fontsize=10)
© www.soinside.com 2019 - 2024. All rights reserved.