I am creating some graphs using Matplotlib and later saving them using 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!
CodePudding user response:
You can rotate the xticks
using:
plt.xticks(rotation=45)