Thanks Eric - unfortunately I need to be able to resize the figure
interactively and have the axes follow.
So an alternative that would be equally useful for me would be to
specify axes using add_subplot or add_axes but then essentially have
an option to say that the distance to the edge of the figure should be
preserved when resizing. In other words, I'm not too concerned about
whether I specify the original axes position in relative units or in
inches, but the important thing is that the distance to the edge of
the figure stays constant in absolute terms.
Is this something that would be easy to build as an Axes subclass?
Cheers,
Tom
···
On 9 September 2015 at 23:12, Eric Firing <efiring@...202...> wrote:
On 2015/09/09 11:01 AM, Thomas Robitaille wrote:
Hi everyone,
I am interested in creating axes in an interactive figure where the
distance from the spines of the axes to the figure edge are constant
in absolute terms.
To clarify what I mean, when using add_axes([0.1, 0.1, 0.8, 0.8]), the
spines of the axes are always located a distance from the edge of the
figure that is 10% of the size of the figure. However, in my case,
since the font size is constant, I want to be able to say that the
spines should always be e.g. 0.5" from the edge of the figure, which
would avoid wasting space when making the figure larger.
Is there a way to do this currently?
This is what I use for positioning in inches:
def axes_inches(fig, rect, **kw):
"""
Wrapper for Figure.add_axes in which *rect* is given in inches.
The translation to normalized coordinates is done immediately
based on the present figsize.
*rect* is left, bottom, width, height in inches
*kw* are passed to Figure.add_axes
"""
fw = fig.get_figwidth()
fh = fig.get_figheight()
l, b, w, h = rect
relrect = [l / fw, b / fh, w / fw, h / fh]
ax = fig.add_axes(relrect, **kw)
return ax
Note, however, that this works correctly only if you don't change figsize
after calling it, so maybe it is not what you are looking for.
Eric
(I am aware of set_tight_layout which would result in something
similar, but this is not what I am after - I would like to be able to
specify the exact absolute distance from the figure edge)
Thanks!
Tom
------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
I managed to write an Axes sub-class to do this:
https://gist.github.com/astrofrog/8d579ea83e578a9cdb99
Try running this then resize the figure and the margin between axes
and figure edge will stay constant.
Is this something that would be useful to have in Matplotlib itself? I
could foresee something like:
fig.add_axes([0.1, 0.1, 0.8, 0.8], preserve_absolute_margins=True)
If this would be useful, I can open a pull request.
Cheers,
Tom
···
On 9 September 2015 at 23:29, Thomas Robitaille <thomas.robitaille@...287...> wrote:
Thanks Eric - unfortunately I need to be able to resize the figure
interactively and have the axes follow.
So an alternative that would be equally useful for me would be to
specify axes using add_subplot or add_axes but then essentially have
an option to say that the distance to the edge of the figure should be
preserved when resizing. In other words, I'm not too concerned about
whether I specify the original axes position in relative units or in
inches, but the important thing is that the distance to the edge of
the figure stays constant in absolute terms.
Is this something that would be easy to build as an Axes subclass?
Cheers,
Tom
On 9 September 2015 at 23:12, Eric Firing <efiring@...202...> wrote:
On 2015/09/09 11:01 AM, Thomas Robitaille wrote:
Hi everyone,
I am interested in creating axes in an interactive figure where the
distance from the spines of the axes to the figure edge are constant
in absolute terms.
To clarify what I mean, when using add_axes([0.1, 0.1, 0.8, 0.8]), the
spines of the axes are always located a distance from the edge of the
figure that is 10% of the size of the figure. However, in my case,
since the font size is constant, I want to be able to say that the
spines should always be e.g. 0.5" from the edge of the figure, which
would avoid wasting space when making the figure larger.
Is there a way to do this currently?
This is what I use for positioning in inches:
def axes_inches(fig, rect, **kw):
"""
Wrapper for Figure.add_axes in which *rect* is given in inches.
The translation to normalized coordinates is done immediately
based on the present figsize.
*rect* is left, bottom, width, height in inches
*kw* are passed to Figure.add_axes
"""
fw = fig.get_figwidth()
fh = fig.get_figheight()
l, b, w, h = rect
relrect = [l / fw, b / fh, w / fw, h / fh]
ax = fig.add_axes(relrect, **kw)
return ax
Note, however, that this works correctly only if you don't change figsize
after calling it, so maybe it is not what you are looking for.
Eric
(I am aware of set_tight_layout which would result in something
similar, but this is not what I am after - I would like to be able to
specify the exact absolute distance from the figure edge)
Thanks!
Tom
------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
What might be more generally useful is to make it easier to specify which coordinate system you wish some spec to apply to. To be frank, I can never keep the transform names straight, and it isn’t possible to specify it at all in some places.
···
On Sep 9, 2015 6:04 PM, “Thomas Robitaille” <thomas.robitaille@…287…> wrote:
I managed to write an Axes sub-class to do this:
https://gist.github.com/astrofrog/8d579ea83e578a9cdb99
Try running this then resize the figure and the margin between axes
and figure edge will stay constant.
Is this something that would be useful to have in Matplotlib itself? I
could foresee something like:
fig.add_axes([0.1, 0.1, 0.8, 0.8], preserve_absolute_margins=True)
If this would be useful, I can open a pull request.
Cheers,
Tom
On 9 September 2015 at 23:29, Thomas Robitaille > > <thomas.robitaille@…1972…> wrote:
Thanks Eric - unfortunately I need to be able to resize the figure
interactively and have the axes follow.
So an alternative that would be equally useful for me would be to
specify axes using add_subplot or add_axes but then essentially have
an option to say that the distance to the edge of the figure should be
preserved when resizing. In other words, I’m not too concerned about
whether I specify the original axes position in relative units or in
inches, but the important thing is that the distance to the edge of
the figure stays constant in absolute terms.
Is this something that would be easy to build as an Axes subclass?
Cheers,
Tom
On 9 September 2015 at 23:12, Eric Firing <efiring@…202…> wrote:
On 2015/09/09 11:01 AM, Thomas Robitaille wrote:
Hi everyone,
I am interested in creating axes in an interactive figure where the
distance from the spines of the axes to the figure edge are constant
in absolute terms.
To clarify what I mean, when using add_axes([0.1, 0.1, 0.8, 0.8]), the
spines of the axes are always located a distance from the edge of the
figure that is 10% of the size of the figure. However, in my case,
since the font size is constant, I want to be able to say that the
spines should always be e.g. 0.5" from the edge of the figure, which
would avoid wasting space when making the figure larger.
Is there a way to do this currently?
This is what I use for positioning in inches:
def axes_inches(fig, rect, **kw):
"""
Wrapper for Figure.add_axes in which *rect* is given in inches.
The translation to normalized coordinates is done immediately
based on the present figsize.
*rect* is left, bottom, width, height in inches
*kw* are passed to Figure.add_axes
"""
fw = fig.get_figwidth()
fh = fig.get_figheight()
l, b, w, h = rect
relrect = [l / fw, b / fh, w / fw, h / fh]
ax = fig.add_axes(relrect, **kw)
return ax
Note, however, that this works correctly only if you don’t change figsize
after calling it, so maybe it is not what you are looking for.
Eric
(I am aware of set_tight_layout which would result in something
similar, but this is not what I am after - I would like to be able to
specify the exact absolute distance from the figure edge)
Thanks!
Tom
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users