[Matplotlib-users] Unusual layout (GridSpec?)
bruno.pagani at astrophysics.eu
Thu Sep 26 15:33:50 EDT 2019
Thank you both for your advices. I was hoping for a GridSpec solution
because I think such a one would have been able to leverage
constrained_layout to automatically fit the space correctly. There might
exists one, but I did not had a lot of time for researching.
Instead, I went with Eric’s PoC that I was able to tweak nicely in order
to suit my needs (btw Eric, the attached script was perfectly received
on my end). The end result is attached to this email. So many thanks for
that piece of code Eric, it proved to be very helpful. ;)
Le 20/09/2019 à 00:01, Eric Firing a écrit :
> I don't think this is what gridspec is for, or can handle. Instead, I
> think you will have to use a very manual approach to figure out the
> positions of the Axes objects that will make them and their tick
> locations line up as desired. An example is in the attached script.
> Caution: the example will work correctly only if your dpi setting is
> such that the specified figsize can be fully displayed on your screen;
> if it is too big, mpl will shrink it to fit, and then all the
> calculations will be out of whack.
> On 2019/09/19 10:39 AM, Paul Hobson wrote:
>> I don't think I understand your problem fully, but a GridSpec sounds
>> like it'll fit the bill. We have a tutorial on it at our website.
>> You'll probably get the most mileage out of the width_ratios and
>> height_ratios parameters:
>> On Thu, Sep 19, 2019 at 12:02 PM Bruno Pagani
>> <bruno.pagani at astrophysics.eu <mailto:bruno.pagani at astrophysics.eu>>
>> 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
>> 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
>> labels to be shared amongst the three graphs. Same goes for the
>> (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
>> other label")
>> another label")
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 35086 bytes
Desc: not available
More information about the Matplotlib-users