Reputation: 1020
looking for some "magic" command that make the maps of the subplots (2x2 in my case) well speared not too much but with the right spacing in order to be considered "quality plot" I found that i can set all using the option rect inside plt.tight_layout
I spend time to find this parameters : plt.tight_layout(rect=(0.02,0.02,0.97,0.97))
Now the plot is fitting well the pdf image but the 2 plots of the top is to close to the 2 below look the picture without going out of bound on the top ? and how can obtain the plot title a bit more separate respect the figure ? hope in your hint !
EDIT ok .. if I use the command plt.title('...',y=1.1)
this is taken just on the last plot (the axs[1,1]) while I'm write the command before all the subplot !
Upvotes: 1
Views: 220
Reputation: 39072
Sorry I don't have an answer for automatic resizing but since you asked for some hints, there is one possible solution:
https://matplotlib.org/api/_as_gen/matplotlib.pyplot.subplots_adjust.html
What you need is wspace for horizontal spacing and hspace for horizontal spacing between the subplots. This gives you freedom to choose the desired spacing to make your plot a "quality plot". Hope it helps.
As to your second question about placing the title, you can use:
plt.title("Title here", y=1.25)
where y defines the position of your title in relative coordinates. y=1 would mean at the top x-axis and y=0.5 would mean in the centre of the plot. Since you have a title for each subplot, you can use the respective relative coordinates for each.
Upvotes: 1