[英]X-axis labels getting overlapped while saving matplotlib graph
I am creating some graphs using Matplotlib and later saving them using plt.savefig()
我正在使用 Matplotlib 创建一些图表,然后使用
plt.savefig()
保存它们
import matplotlib.pyplot as plt
plt.plot(date_list, variable_proj_hr_list, label=prj) # hours vs dates graph
plt.xlabel('Dates')
plt.ylabel('Hours')
plt.title('Hours spent by the team on different Projects day-wise')
plt.legend()
plt.savefig('img1.jpg')
But the image gets saved as follows with all the dates overlapped -但是图像被保存如下,所有日期都重叠了 -
Is there any way I can get the dates not to overlap?有什么办法可以让日期不重叠?
Even if I can maybe increase the width of the image while saving it, or get the dates tilted at an angle such that they appear distinct can solve the problem for me即使我可以在保存图像的同时增加图像的宽度,或者让日期倾斜一个角度使它们看起来不同,也可以为我解决问题
Any help is highly appreciated!非常感谢任何帮助!
You can rotate the xticks
using:您可以使用以下方法旋转
xticks
:
plt.xticks(rotation=45)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.