Question Details

No question body available.

Tags

python matplotlib whitespace subplot

Answers (1)

Accepted Answer Available
Accepted Answer
August 5, 2025 Score: 6 Rep: 386 Quality: Expert Completeness: 80%

If I understood you correctly and you need the result as shown in the picture without using fig.subplotsadjust.

Example result plot

You can build your code based on the widthratios parameter in the fig.addgridspec() function. The code that builds the picture above.

import matplotlib.pyplot as plt
import numpy as np
import scipy.stats as stats

data = np.random.normal(0, 1, 1000)

fig = plt.figure(figsize=(10, 4)) gs = fig.addgridspec(1, 7, widthratios=[1.5, 0.5, 1, 0.00, 1, 0.00, 1], wspace=0)

First plot (hist)

axhist = fig.addsubplot(gs[0]) axhist.hist([1, 2, 3], bins=30, edgecolor='black') axhist.setylabel('Count') axhist.setxlabel('Val')

quantiles

axqq = [fig.add
subplot(gs[i]) for i in range(2, 7, 2)] stats.probplot(data, dist="norm", plot=axqq[0]) axqq[0].setylabel('Ylabel')

for ax in axqq[1:]: stats.probplot(data, dist="norm", plot=ax) # Delete all info for Y axis ax.setylabel(None) ax.setyticklabels([]) ax.setyticks([]) ax.spines['left'].setvisible(False) ax.getyaxis().setvisible(False)

plt.show()