Johann Rohwer wrote:
I'm trying to insert a custom set of axes within a subplot, much like the axes_demo.py. Only difference is, now I want an inset graph inside each of a number of subplots. Using ASCII art, much like the following:
>-------------------|
> >
> ----- |
> > > >
> ----- |
>-------------------|
>-------------------|
> >
> ----- |
> > > >
> ----- |
>-------------------|
Where the whole thing would be the figure, containing 2 subplots each with an inset.
Is there any way to have the rect coordinates of
fig.add_axes(rect)
to refer to the axes coordinates of the respective subplot, and not of the complete figure? (In reality there are actually 12 subplots, not only 2....
To answer my own question, after browsing the docstrings I came up with the following attached minimal script to illustrate a solution to the problem. However, it appears crufty. Specifically,
1. Can the fig.add_axes() call not take a transform directly as optional argument, like in fig.add_axes([.4, .1, .5, .3], transform=ax.transAxes)? This would appear the natural solution but does not work.
2. The transformed bounding box gives coordinates in points, necessitating the division by figure width and figure height to revert back to fractional coordinates.
3. Re-calculating [l, b, w, h] from tBbox seems cumbersome. Can the add_axes() not call a Bbox instance directly?
I'm sure I'm missing something obvious but don't have the time to delve into the transforms sourcecode, so any pointer is appreciated
Johann
sub_subplot.py (752 Bytes)