Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

subplots are overlapping axis labels [duplicate]

I have created a figure in python which contains multiple subplots. I have also added various axis labels to some of the axes on the figures. For examples:

plt.xlabel('Phase ($^\circ$)',fontsize=10)

I notice though, that when the final figure is produced, the other subplots are allowed to overlap and obscure the words of the axis labels.

Is there a way that I can stop this happening?

like image 943
user1551817 Avatar asked Nov 05 '12 08:11

user1551817


People also ask

How do I stop subplots from overlapping?

Often you may use subplots to display multiple plots alongside each other in Matplotlib. Unfortunately, these subplots tend to overlap each other by default. The easiest way to resolve this issue is by using the Matplotlib tight_layout() function.

How do you stop labels overlapping in Matplotlib?

Use legend() method to avoid overlapping of labels and autopct. To display the figure, use show() method.

How do you stop overlapping in Seaborn?

Faceting is one of the methods you can use to avoid overlapping. Seaborn has a function FacetGrid() for faceting.


1 Answers

just add the following:

plt.tight_layout()

I hope it helps. Link to documentation.

like image 74
Emm Avatar answered Sep 20 '22 15:09

Emm