[英]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()
输出:
设置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)
另一种可能性是增加整个绘图的大小,具体方法如下: 如何更改用matplotlib绘制的图形的大小?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.