Xaxis Text Overlapping - Matplotlib
I plot a bar graph using matplotlib and everything works fine. When the 'text label' on X-axis is too lengthy for each data point, then the text overlaps like shown in the figure.
Solution 1:
The best I can come up with is set the rotation as vertical changing the figure extension and run a plt.tight_layout().
Those would be the last 3 lines of your code:
mngr = plt.get_current_fig_manager()
mngr.window.setGeometry(50,50,960, 640)
plt.tight_layout()
Alternatively, you should use multi lines with \n.
See http://matplotlib.org/examples/pylab_examples/multiline.html
Solution 2:
Below solution worked for me
How to prevent overlapping x-axis labels in sns.countplot
plt.xticks(
    rotation=45, 
    horizontalalignment='right',
    fontweight='light',
    fontsize='x-large'  
)
Post a Comment for "Xaxis Text Overlapping - Matplotlib"