DavidC.
DavidC.

Reputation: 677

subplots from one figure to have the same dimensions as subplots from other figure

The following code:

import matplotlib.pyplot as plt

fig, axes = plt.subplots(ncols=3, nrows=4, sharex='col', sharey=False,\
            subplot_kw=dict(adjustable='box-forced'), figsize=(8, 8))

fig, axes = plt.subplots(ncols=3, nrows=3, sharex='col', sharey=False,\
            subplot_kw=dict(adjustable='box-forced'), figsize=(8, 8))    
plt.show()

produces two plots:

The first plot has subplots distributed as ncols=3, nrows=4. The size of each of these subplots is perfect for my need.

enter image description here

The second plot has subplots distributed as ncols=3, nrows=3:

enter image description here

How could I make each of these subplots have the same dimensions as the subplots from the first plot?

Upvotes: 0

Views: 54

Answers (1)

Scott Boston
Scott Boston

Reputation: 153460

One way is set that last line as "invisible":

import matplotlib.pyplot as plt

fig, axes = plt.subplots(ncols=3, nrows=4, sharex='col', sharey=False,\
            subplot_kw=dict(adjustable='box-forced'), figsize=(8, 8))

fig, axes = plt.subplots(ncols=3, nrows=4, sharex='col', sharey=False,\
            subplot_kw=dict(adjustable='box-forced'), figsize=(8, 8))

[ax.set_visible(False) for ax in axes[3,:]]
plt.show()

enter image description here

enter image description here

Upvotes: 2

Related Questions