A7sharp11
A7sharp11

Reputation: 123

Matplotlib: Getting subplot position values (hspace, wspace, ..)

I have changed the spacing of my subplots successfully with the Subplot Configuration Tool (accessible in the figure window), now I would like to actually get the values of the properties I just set: hspace, wspace etc.

Where can I find these?

I tried plt.getp(plt.axes()), along with other objects as argument to getp but have had no luck in finding them so far.

Upvotes: 6

Views: 1704

Answers (1)

Paul H
Paul H

Reputation: 68126

You want to use fig.subplotpars

from matplotlib import pyplot

fig, axes = pyplot.subplots(nrows=2, ncols=2)
fig.subplots_adjust(hspace=0.5)

print(fig.subplotpars.hspace, fig.subplotpars.wspace, sep='; ')

And that prints:

0.5; 0.2

Upvotes: 6

Related Questions