Skip to content
Advertisement

Matplotlib different size subplots

I need to add two subplots to a figure. One subplot needs to be about three times as wide as the second (same height). I accomplished this using GridSpec and the colspan argument but I would like to do this using figure so I can save to PDF. I can adjust the first figure using the figsize argument in the constructor, but how do I change the size of the second plot?

Advertisement

Answer

f, (a0, a1) = plt.subplots(1, 2, width_ratios=[3, 1])

f, (a0, a1, a2) = plt.subplots(3, 1, height_ratios=[1, 1, 3])


JavaScript

enter image description here

  • Because the question is canonical, here is an example with vertical subplots.
JavaScript

enter image description here

Advertisement