Vertical space manipulation in matplotlib subtitles

I want to reduce the vertical distance between the subtitle. Surfing the net I just found how to reduce the horizontal spacing, something like

import matplotlib.pyplot as plt fig, axes = plt.subplots(nrows=4, ncols=4) fig.tight_layout() # Or equivalently, "plt.tight_layout()" fig.subplots_adjust(hspace=0.5) plt.show() 

The hspace thing is the one that controls this behavior, but apparently there is no vspace.

EDIT:

This does not reduce the space between the y axis, and this is what I want to manipulate.

+5
source share
1 answer

As you said in your hspace question, the vertical distance between the subtitles is decreasing. The equivalent for the horizontal distance between subheadings is wspace . The following is an example:

 x = np.linspace(0, 2 * np.pi, 400) y = np.sin(x ** 2) fig, ((ax1,ax2),(ax3,ax4)) = plt.subplots(nrows=2, ncols=2) fig.tight_layout() ax1.plot(x, y) ax2.scatter(x, y) ax3.scatter(x, y) ax4.scatter(x, y) fig.subplots_adjust(wspace=0.2) plt.show() 

Using the value for 1 for wspace gives enter image description here

Using 0.2 as the value of wspace , we get

enter image description here

+6
source

Source: https://habr.com/ru/post/1244311/


All Articles