zoomed in detail box

Hi,

I'm sure its a bit lazy to ask but I can't think of the right keywords
to search for...

I would like to produce a plot with a zoomed in box detail section.
What I have in mind is a plot of an exponentially decaying line with
some fine detail, so I would like the main plot to show the scale of
the exponential decay, but then in the large space in the
center/top/right of the plot I would like to have a zoomed in box
showing more detail of a particular bit to show the level of the noise
etc.

No idea where to start with acheiving this so I thought I'd ask if
anyone has done anything similar or if there would be any examples on
the web site - or whether it would be easier just to produce 2 plots
at different scales then chop them together in a graphics editing
program. (I thought of inkscape, but in the past when I've tried to
edit matplotlib vector output it messed up the fonts - or at least
changed them - so I'm not sure if theres a better program, or some
trick to using it).

Cheers

Robin

If you use the svn version of matplotlib, you may use axes_grid toolkit.

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#insetlocator

I think the required inset_locator module actually does not depend on
other modules in axes_grid, so if you're not using svn, you may just
download inset_locator.py and use it.
But still, you need to have 0.98.5.3 installed.

-JJ

···

On Wed, Jul 8, 2009 at 6:24 AM, Robin<robince@...287...> wrote:

Hi,

I'm sure its a bit lazy to ask but I can't think of the right keywords
to search for...

I would like to produce a plot with a zoomed in box detail section.
What I have in mind is a plot of an exponentially decaying line with
some fine detail, so I would like the main plot to show the scale of
the exponential decay, but then in the large space in the
center/top/right of the plot I would like to have a zoomed in box
showing more detail of a particular bit to show the level of the noise
etc.

No idea where to start with acheiving this so I thought I'd ask if
anyone has done anything similar or if there would be any examples on
the web site - or whether it would be easier just to produce 2 plots
at different scales then chop them together in a graphics editing
program. (I thought of inkscape, but in the past when I've tried to
edit matplotlib vector output it messed up the fonts - or at least
changed them - so I'm not sure if theres a better program, or some
trick to using it).

Cheers

Robin

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Arrrg,
it depends on other module in axes_grid toolkit.
So, you need svn version of mpl.

However, It is possible to specify the location of the axes in
normalized axes coordinate.

http://thread.gmane.org/gmane.comp.python.matplotlib.general/16373

-JJ

···

On Wed, Jul 8, 2009 at 10:57 PM, Jae-Joon Lee<lee.j.joon@...287...> wrote:

If you use the svn version of matplotlib, you may use axes_grid toolkit.

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#insetlocator

I think the required inset_locator module actually does not depend on
other modules in axes_grid, so if you're not using svn, you may just
download inset_locator.py and use it.
But still, you need to have 0.98.5.3 installed.

matplotlib download | SourceForge.net

-JJ

On Wed, Jul 8, 2009 at 6:24 AM, Robin<robince@...287...> wrote:

Hi,

I'm sure its a bit lazy to ask but I can't think of the right keywords
to search for...

I would like to produce a plot with a zoomed in box detail section.
What I have in mind is a plot of an exponentially decaying line with
some fine detail, so I would like the main plot to show the scale of
the exponential decay, but then in the large space in the
center/top/right of the plot I would like to have a zoomed in box
showing more detail of a particular bit to show the level of the noise
etc.

No idea where to start with acheiving this so I thought I'd ask if
anyone has done anything similar or if there would be any examples on
the web site - or whether it would be easier just to produce 2 plots
at different scales then chop them together in a graphics editing
program. (I thought of inkscape, but in the past when I've tried to
edit matplotlib vector output it messed up the fonts - or at least
changed them - so I'm not sure if theres a better program, or some
trick to using it).

Cheers

Robin

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

If you use the svn version of matplotlib, you may use axes_grid toolkit.

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#insetlocator

Wow - this is really amazing. Sometimes it can be a bit frustrating
when I'm working to a deadline to figure out the details of Bbox's and
such but when I find something like this it really makes it worth
while! It does exactly what I want, really easy to use and only took
about 5 lines! (It would be nice if there were some docstrings in
there though :))

However, It is possible to specify the location of the axes in
normalized axes coordinate.

http://thread.gmane.org/gmane.comp.python.matplotlib.general/16373

I'm afraid I didn't really understand how to apply this in my case...
I guess I would have to set the position and everything by hand
instead of using the zoom helper. I preferred to use the zoom helper,
but found the legend loc settings put it slightly too close to the
edge of the surrounding axes for my taste.

So after checking the docstrings for how to position legends I came up
with something that works, but it required a minor change to the
inset_locator.py to pass the bbox_to_anchor and bbox_transform (it
looks like this was intended since they have None default values):

robin-mbp-3:~ robince$ diff
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/mpl_toolkits/axes_grid/inset_locator.py
code/scipy_build/matplotlib/lib/mpl_toolkits/axes_grid/inset_locator.py
288c288
< axes_locator = AnchoredZoomLocator(parent_axes, zoom=zoom,
loc=loc, bbox_to_anchor=bbox_to_anchor,bbox_transform=bbox_transform)

···

On Wed, Jul 8, 2009 at 10:57 PM, Jae-Joon Lee<lee.j.joon@...287...> wrote:

On Thu, Jul 9, 2009 at 4:02 AM, Jae-Joon Lee<lee.j.joon@...287...> wrote:
---

   axes_locator = AnchoredZoomLocator(parent_axes, zoom=zoom, loc=loc)

With this minor change I get exactly what I want!

   ax1ins = zoomed_inset_axes(ax1, 3,
bbox_to_anchor=(0.1,0,1,1),bbox_transform=ax1.transAxes, loc=6)
    plot_trial_dists(res515[0],8,ax=ax1ins)
    ax1ins.set_xlim([5, 50])
    ax1ins.set_ylim([0, 0.04])
    ax1ins.set_xticks()
    ax1ins.set_yticks()
    mark_inset(ax1, ax1ins, loc1=2, loc2=4, fc="none", ec="0.5")

thanks again, this is really terrific!

Cheers

Robin

If you use the svn version of matplotlib, you may use axes_grid toolkit.

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html#insetlocator

Wow - this is really amazing. Sometimes it can be a bit frustrating
when I'm working to a deadline to figure out the details of Bbox's and
such but when I find something like this it really makes it worth
while! It does exactly what I want, really easy to use and only took
about 5 lines! (It would be nice if there were some docstrings in
there though :))

However, It is possible to specify the location of the axes in
normalized axes coordinate.

http://thread.gmane.org/gmane.comp.python.matplotlib.general/16373

I'm afraid I didn't really understand how to apply this in my case...
I guess I would have to set the position and everything by hand
instead of using the zoom helper. I preferred to use the zoom helper,
but found the legend loc settings put it slightly too close to the
edge of the surrounding axes for my taste.

So after checking the docstrings for how to position legends I came up
with something that works, but it required a minor change to the
inset_locator.py to pass the bbox_to_anchor and bbox_transform (it
looks like this was intended since they have None default values):

robin-mbp-3:~ robince$ diff
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/mpl_toolkits/axes_grid/inset_locator.py
code/scipy_build/matplotlib/lib/mpl_toolkits/axes_grid/inset_locator.py
288c288
< axes_locator = AnchoredZoomLocator(parent_axes, zoom=zoom,
loc=loc, bbox_to_anchor=bbox_to_anchor,bbox_transform=bbox_transform)
---

axes_locator = AnchoredZoomLocator(parent_axes, zoom=zoom, loc=loc)

With this minor change I get exactly what I want!

Thanks for the catch. I'll commit the change to the svn soon.
By the way, borderpad keyword is meant to do what you want. However, I
just found that it does not work sine the option is not properly
handled. I'll fix this in the next commit.

Regards,

-JJ

···

On Thu, Jul 9, 2009 at 7:24 AM, Robin<robince@...287...> wrote:

On Wed, Jul 8, 2009 at 10:57 PM, Jae-Joon Lee<lee.j.joon@...287...> wrote:

On Thu, Jul 9, 2009 at 4:02 AM, Jae-Joon Lee<lee.j.joon@...287...> wrote:

ax1ins = zoomed_inset_axes(ax1, 3,
bbox_to_anchor=(0.1,0,1,1),bbox_transform=ax1.transAxes, loc=6)
plot_trial_dists(res515[0],8,ax=ax1ins)
ax1ins.set_xlim([5, 50])
ax1ins.set_ylim([0, 0.04])
ax1ins.set_xticks()
ax1ins.set_yticks()
mark_inset(ax1, ax1ins, loc1=2, loc2=4, fc="none", ec="0.5")

thanks again, this is really terrific!

Cheers

Robin