ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 19 Aug 2010 16:59:09 -0500How to plot a zoomed part in a matplotlib figure in sage?http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/Hi, I'm trying to zoom one part of my figure in Matplotlib.
In the Matplotlib-Galery, I found this nice example using
mpl_toolkits.axes_grid.inset_locator
http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/inset_locator_demo.py
The result is
http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/inset_locator_demo.hires.png
which is pretty much what I need.
Does anybody know how to do this in sage?
I didn't manage to use this function in sage. (In fact, I even didn't find it)
Thanks!Thu, 19 Aug 2010 06:55:29 -0500http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/Answer by cswiercz for <p>Hi, I'm trying to zoom one part of my figure in Matplotlib.
In the Matplotlib-Galery, I found this nice example using
mpl_toolkits.axes_grid.inset_locator</p>
<p><a href="http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/inset_locator_demo.py">http://matplotlib.sourceforge.net/plo...</a></p>
<p>The result is
<a href="http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/inset_locator_demo.hires.png">http://matplotlib.sourceforge.net/plo...</a></p>
<p>which is pretty much what I need.</p>
<p>Does anybody know how to do this in sage?
I didn't manage to use this function in sage. (In fact, I even didn't find it)</p>
<p>Thanks!</p>
http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/?answer=11438#post-id-11438From what I understand the Sage Notebook displays a plot if a .png file is created in the directory corresponding to the cell. Thus, plt.savefig('.') also works. Also, be sure to set **hold(False)** if you want the same behavior as Sage's **plot** command. Otherwise, your plots will continue to overlap.
Since I use Pylab extensively for numerics, I have a published Sage Notebook here demonstrating plotting in Sage using matplotlib trough Pylab: <a href="http://uw.sagenb.org/home/pub/9/">http://uw.sagenb.org/home/pub/9/</a>. You'll get similar behavior when you use **import matplotlib.pyplot** instead.
(I would've posted this as a comment to kcrisman's answer above but ASKBOT is giving some strange errors.)Thu, 19 Aug 2010 08:10:29 -0500http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/?answer=11438#post-id-11438Answer by kcrisman for <p>Hi, I'm trying to zoom one part of my figure in Matplotlib.
In the Matplotlib-Galery, I found this nice example using
mpl_toolkits.axes_grid.inset_locator</p>
<p><a href="http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/inset_locator_demo.py">http://matplotlib.sourceforge.net/plo...</a></p>
<p>The result is
<a href="http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/inset_locator_demo.hires.png">http://matplotlib.sourceforge.net/plo...</a></p>
<p>which is pretty much what I need.</p>
<p>Does anybody know how to do this in sage?
I didn't manage to use this function in sage. (In fact, I even didn't find it)</p>
<p>Thanks!</p>
http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/?answer=11437#post-id-11437Apparently our Matplotlib (matplotlib-0.99.3) does not have `mpl_toolkits.axes_grid1`, which is needed for that example. The same example would work in Sage if you used `mpl_toolkits.axes_grid`, except `plt.show()` doesn't necessarily work from within Sage, so for instance `plt.savefig('test.png')` would work to save it in your home directory.
Thu, 19 Aug 2010 07:47:20 -0500http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/?answer=11437#post-id-11437Comment by Jason Grout for <p>Apparently our Matplotlib (matplotlib-0.99.3) does not have <code>mpl_toolkits.axes_grid1</code>, which is needed for that example. The same example would work in Sage if you used <code>mpl_toolkits.axes_grid</code>, except <code>plt.show()</code> doesn't necessarily work from within Sage, so for instance <code>plt.savefig('test.png')</code> would work to save it in your home directory.</p>
http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/?comment=23000#post-id-23000See http://trac.sagemath.org/sage_trac/ticket/9221 for the upgrade trac ticket (upgrade to matplotlib 1.0)Thu, 19 Aug 2010 16:58:44 -0500http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/?comment=23000#post-id-23000Comment by Jason Grout for <p>Apparently our Matplotlib (matplotlib-0.99.3) does not have <code>mpl_toolkits.axes_grid1</code>, which is needed for that example. The same example would work in Sage if you used <code>mpl_toolkits.axes_grid</code>, except <code>plt.show()</code> doesn't necessarily work from within Sage, so for instance <code>plt.savefig('test.png')</code> would work to save it in your home directory.</p>
http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/?comment=22999#post-id-22999See trac #9221 for the upgrade trac ticket (upgrade to matplotlib 1.0)Thu, 19 Aug 2010 16:59:09 -0500http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/?comment=22999#post-id-22999Answer by twk for <p>Hi, I'm trying to zoom one part of my figure in Matplotlib.
In the Matplotlib-Galery, I found this nice example using
mpl_toolkits.axes_grid.inset_locator</p>
<p><a href="http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/inset_locator_demo.py">http://matplotlib.sourceforge.net/plo...</a></p>
<p>The result is
<a href="http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/inset_locator_demo.hires.png">http://matplotlib.sourceforge.net/plo...</a></p>
<p>which is pretty much what I need.</p>
<p>Does anybody know how to do this in sage?
I didn't manage to use this function in sage. (In fact, I even didn't find it)</p>
<p>Thanks!</p>
http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/?answer=11454#post-id-11454Hi,
Thanks for your answers.
In the mean time, I tried on my own and made it.
I wanted to answer my own question but I get ugly errors when I do so...Thu, 19 Aug 2010 09:58:12 -0500http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/?answer=11454#post-id-11454Answer by twk for <p>Hi, I'm trying to zoom one part of my figure in Matplotlib.
In the Matplotlib-Galery, I found this nice example using
mpl_toolkits.axes_grid.inset_locator</p>
<p><a href="http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/inset_locator_demo.py">http://matplotlib.sourceforge.net/plo...</a></p>
<p>The result is
<a href="http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/inset_locator_demo.hires.png">http://matplotlib.sourceforge.net/plo...</a></p>
<p>which is pretty much what I need.</p>
<p>Does anybody know how to do this in sage?
I didn't manage to use this function in sage. (In fact, I even didn't find it)</p>
<p>Thanks!</p>
http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/?answer=11451#post-id-11451Hi,
Thanks for your answers.
In the mean time, I tried on my own and made it.
Unfortunately, I had to use some very dirty tricks and finally just copied the file
"inset_locator.py"
from
"/usr/lib/pymodules/python2.6/mpl_toolkits/axes_grid"
to
'sage/local/lib/python2.6/site-packages/mpl_toolkits/axes_grid'
I don't know about possible bugs, but I got the needed result.
By the way...how can I get this message to view the underlines _ ?
Maybe a topic for a new question..
Thanks,
TobiThu, 19 Aug 2010 09:53:50 -0500http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/?answer=11451#post-id-11451Answer by twk for <p>Hi, I'm trying to zoom one part of my figure in Matplotlib.
In the Matplotlib-Galery, I found this nice example using
mpl_toolkits.axes_grid.inset_locator</p>
<p><a href="http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/inset_locator_demo.py">http://matplotlib.sourceforge.net/plo...</a></p>
<p>The result is
<a href="http://matplotlib.sourceforge.net/plot_directive/mpl_toolkits/axes_grid/examples/inset_locator_demo.hires.png">http://matplotlib.sourceforge.net/plo...</a></p>
<p>which is pretty much what I need.</p>
<p>Does anybody know how to do this in sage?
I didn't manage to use this function in sage. (In fact, I even didn't find it)</p>
<p>Thanks!</p>
http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/?answer=11452#post-id-11452Hi,
Thanks for your answers.
In the mean time, I tried on my own and made it.
Unfortunately, I had to use some very dirty tricks and finally just copied the file
`inset_locator.py`
from
`/usr/lib/pymodules/python2.6/mpl_toolkits/axes_grid`
to
`sage/local/lib/python2.6/site-packages/mpl_toolkits/axes_grid`
I don't know about possible bugs, but I got the needed result.
By the way...how can I get this message to view the underlines _ ?
Maybe a topic for a new question..
Thanks,
TobiThu, 19 Aug 2010 09:55:21 -0500http://ask.sagemath.org/question/7591/how-to-plot-a-zoomed-part-in-a-matplotlib-figure-in-sage/?answer=11452#post-id-11452