'X-axis labels getting overlapped while saving matplotlib graph
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!
Solution 1:[1]
You can rotate the xticks using:
plt.xticks(rotation=45)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Abhyuday Vaish |

