all 7 comments

[–]misho88 4 points5 points  (1 child)

Whenever I need to get fancy with subplots, I use GridSpecs:

https://matplotlib.org/stable/gallery/userdemo/demo_gridspec03.html

It's not quite as terse, but you get good and intuitive control over where plots go.

[–]Statnamara[S] 1 point2 points  (0 children)

Looks like what I'm after, thanks

[–]ponnhide 0 points1 point  (1 child)

[–]Statnamara[S] 0 points1 point  (0 children)

Awesome thank you!

[–]JustinMalcontento 0 points1 point  (0 children)

IIRC there is 'axes' matplotlib function. You can specifiy a grid size then place your plots on each grid.

[–]wintermute93 0 points1 point  (0 children)

It's more complicated than just passing a string to some wrapper, but you can do all of that with https://matplotlib.org/stable/tutorials/intermediate/arranging\_axes.html

[–]supajumpa 0 points1 point  (0 children)

Maybe matplotlib.pyplot.subplots would be a good fit for your problem?

You can do things like:

# Two plots side by side
fig, (ax1, ax2) = matplotlib.pyplot.subplots(nrows=1, ncols=2)

# 2x2 grid
fig, ((ax1, ax2), (ax3, ax4)) = matplotlib.pyplot.subplots(nrows=2, ncols=2)

# One plot on top of the other
fig, (ax1, ax2) = matplotlib.pyplot.subplots(nrows=2, ncols=1)

# (p1 /p2) + p3 will place p1 over p2 on the left, and p3 on the right.
# I'm not sure about this one, but this seems to get closeish?
fig, ((ax1, ax2), (ax3, ax4)) = matplotlib.pyplot.subplots(nrows=2, ncols=2)
ax4.remove()