[Matplotlib-users] Unusual layout (GridSpec?)

Bruno Pagani bruno.pagani at astrophysics.eu
Thu Sep 19 14:55:46 EDT 2019


Hi there,

I’m trying to combine three graphs into one, but with some specific
constraints on the layout. The three graphs are having the same x and y
variables, but not over the same span. Each graph size should reflects
that (e.g. if a change of 1 on the x axis is 1 cm on one graph, so
should it be for the other ones). Also, I’d like the y label and ticks
labels to be shared amongst the three graphs. Same goes for the colorbar
(those are scatter plots) and the legend.

Attached are the three figures (.pdf), and what the combined version
should look like (target.png, but here it was obtained by removing parts
by hand and stretching everything to fit).

Below is some minimal code to produce three similarly looking graphs, if
someone has an idea (GridSpec?) for this, I should be able to adapt it
to my actual code:

import matplotlib.pyplot as plt
import numpy as np

plt.scatter(np.repeat(np.linspace(0,3.5,15)[:,None],11,axis=1),np.repeat(np.linspace(0,0.5,11)[None,:],15,axis=0),c=np.random.random((15,11)),label="Some
label")

plt.scatter(np.repeat(np.linspace(0,6,25)[:,None],11,axis=1),np.repeat(np.linspace(0,0.5,11)[None,:],25,axis=0),c=np.random.random((25,11)),marker='*',label="Some
other label")

plt.scatter(np.repeat(np.linspace(0,11,23)[:,None],11,axis=1),np.repeat(np.linspace(0,0.5,11)[None,:],23,axis=0),c=np.random.random((23,11)),marker='D',label="Yet
another label")

Regards,
Bruno

-------------- next part --------------
A non-text attachment was scrubbed...
Name: explosion2.pdf
Type: application/pdf
Size: 21923 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20190919/d97ffbc8/attachment-0003.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: explosion3.pdf
Type: application/pdf
Size: 22579 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20190919/d97ffbc8/attachment-0004.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: explosion4.pdf
Type: application/pdf
Size: 19071 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20190919/d97ffbc8/attachment-0005.pdf>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: target.png
Type: image/png
Size: 256339 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20190919/d97ffbc8/attachment-0001.png>


More information about the Matplotlib-users mailing list