繁体   English   中英

python matplotlib图缩放xaxis和标签

[英]python matplotlib plot scaling xaxis and labels

我的输出有点混乱。 我希望x轴上的状态可见

performance0 = denied_states['STATE'].value_counts().sort_index()
performance1 = certified_states['STATE'].value_counts().sort_index() 
performance2 = cw_states['STATE'].value_counts().sort_index()
performance3 = w_states['STATE'].value_counts().sort_index()
plt.plot( performance0, label = 'Denied')
plt.plot( performance1, label = 'Certified')
plt.plot( performance2, label = 'Certified-Withdrawn')
plt.plot( performance3, label = 'Withdrawn')
plt.xticks(rotation=90)
plt.xlabel('States')

plt.ylabel('Applications')
plt.title('No. of Applicants status of H1B Visa based on states')
plt.legend()
plt.show()

输出:

输出图

  1. 设置xticks语法是:

     xticks(locs, [labels], **kwargs) # Set locations and label 

    **kwargs可能包含Text属性 ,其中包括fontproperties关键字,您可以为其分配FontProperties对象。

    因此,您可以尝试执行以下操作:

     fp = matplotlib.font_manager.FontProperties(family="sans-serif", size=8) # play around with the formatting plt.xticks(rotation=90, fontproperties=fp) 
  2. 另一种可能性是增加整个绘图的大小,具体方法如下: 如何更改用matplotlib绘制的图形的大小?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM