I have a few plots which I would like to stack in a single figure. When
I first came with this problem (back to matplotlib version 0.93 or
older), the most efficient way (at least in my case) of doing this
consisted in playing with transformations as you can see in the cookbook
Unfortunately, this example (and, of course, the script I wrote back
then) doesn't work anymore with with the newest version of Matplotlib
So I started to hack the "mri_with_eeg.py" example to achieve what I
want (since the way EEGs are stacked!)... with no luck!
I probably don't understand well how the transformation works... That's
why I decided to beg for a friendly help!
Here is the code from the example (I focused on the lines I haven't
boxin = Bbox.from_extents(ax.viewLim.x0, -20, ax.viewLim.x1, 20)
height = ax.bbox.height
boxout = Bbox.from_extents(ax.bbox.x0, -1.0 * height,
ax.bbox.x1, 1.0 * height)
transOffset = BboxTransformTo(
Bbox.from_extents(0.0, ax.bbox.y0, 1.0, ax.bbox.y1))
for i in range(numRows):
# effectively a copy of transData
trans = BboxTransform(boxin, boxout)
offset = (i+1)/(numRows+1)
trans += Affine2D().translate(*transOffset.transform_point((0,
thisLine = Line2D(
ax being a AxesSubplot instance
as far as I understood, 20 and -20 (see line where boxin is defined)
refer to min and max values (on Y axis) to be plotted within the space
allocated to each plot (thanks to the tranformation named trans).
In my case Y values can be much higher (roughly from -1e3 to 5e7), so I
should change those values according to mine in order to get the
tranformation working for me. Obviously something is wrong in my
understanding since it doesn't work!
Hence my first question: Why is it not working?
As a bonus, I also have another question: Is there a "new" (i.e.
provided by the new API) way that can be used to stack plots composed by
many (>5k) points?