[Matplotlib-users] First Time asking a question

Matthew Bradley mbatr27 at gmail.com
Thu Jun 7 09:31:03 EDT 2018


Hi all,

This is my first time asking a question on this channel so everyone's help
is appreciated. I'm trying to recreate a figure that my research lab first
created in mathematica (attached in the email). I've tried to recreate the
figure and plot area using the gridspec feature, and it's come close (my
closest attempt is also attached). There are still a few things that need
tweaking like making the lower right plot a square shape, decreasing the
spacing between it and the plot to the left and above it.

Here's my code as a starting point if you wanted to use it. The figure size
doesn't have to be 25:20.

fig = plt.figure(figsize=(25,20))
gs1 = gridspec.GridSpec(7,10)

ax1 = plt.subplot(gs1[1:,0])
ax2 = plt.subplot(gs1[0:6,1])
ax3 = plt.subplot(gs1[1:,3])
ax4 = plt.subplot(gs1[0:6,4])
ax5 = plt.subplot(gs1[1,6])
ax6 = plt.subplot(gs1[0,7])
ax7 = plt.subplot(gs1[0,9])
ax8 = plt.subplot(gs1[4:,6:])
gs1.update(wspace=0.02,hspace=0)


My question is how to do this most efficiently using gridspec or if there
is another feature that makes such a setup a much easier task. I think I
can add more columns and rows to the gridspec and custom define row height
and column width ratios to recreate the plot but that seems like it would
take a lot of trial and error on my part. Likewise if I were to define
multiple gridspecs and define their layouts with the gridspec.update
command would take some guessing and checking. A gridspec within a gridspec
using GridSpecFromSubPlot command might be able to work but it doesn't have
an attribute .update() to customize the wspace between plots in the
gridspec that I know of. Is there a way to define a plots origin (in pixel
or some other coordinates) and its extent?

​Thanks in advance!​


-- 
Matthew Bradley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180607/d50cdac4/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.PNG
Type: image/png
Size: 4174129 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180607/d50cdac4/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: download (1).png
Type: image/png
Size: 23532 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180607/d50cdac4/attachment-0003.png>


More information about the Matplotlib-users mailing list