Re: [Matplotlib-users] [matplotlib-devel] bbox of eps backend : test needed

2010-11-16 Thread Michael Droettboom
Thanks.  With this new script, I get only one failure:

xpdf_False

This is on RHEL5 x86_64:

gs 8.15.2
gv 3.6.8
pdftops 3.00

Cheers,
Mike

On 11/16/2010 06:54 AM, Jae-Joon Lee wrote:
> On Mon, Nov 15, 2010 at 11:29 PM, Michael Droettboom  wrote:
>
>> How do I verify if the bbox is correct?  Displaying them with gs, some of 
>> them have the plot centered on what looks to be a letter-sized page, and 
>> others are at the bottom, but none of them seem to be cropped.  I'm happy to 
>> give a full detailed report, just not sure what I'm looking for in terms of 
>> right/wrong ;)
>>
>> Thanks,
>> Mike
>>
>>  
> Michael,
>
> Here is a slightly modified example.
>
> import matplotlib.pyplot as plt
>
> fig = plt.figure()
> plt.plot([0, 1, 1, 0], [0, 0, 1, 1], "ro", ms=10, transform=fig.transFigure,
>   clip_on=False)
>
> for distiller in ["False", "xpdf", "ghostscript"]:
> for usetex in ["True", "False"]:
> plt.rcParams["ps.usedistiller"]=distiller
> plt.rcParams["text.usetex"]=usetex
>
> plt.savefig("test_bbox_%s_%s.eps" % (distiller, usetex))
>
> With this, you should see four red circles (a quadrant of a circle) at
> the four corner of page boundaries.
> I don't think "gs" is a right tool to test if the bbox is correct. My
> experience is that it often ignores the bbox. On linux, you may use
> "gv", "evince", or "okular".
>
> Regards,
>
> JJ
>


-- 
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA


--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Using matplotlib within pyside

2010-11-16 Thread Benjamin Root
On Tue, Nov 16, 2010 at 8:27 AM, Marc Petersen wrote:

> Hi,
>
> is there a solution for using matplotlib within pyside like it is
> possible with pyqt4?
>
> Greetz
> Marc
>
>
Marc,

Haven't tried it myself, but someone else did ask this a few months ago.

http://old.nabble.com/Matplotlib-and-PySide---td29716125.html

He didn't get far, but maybe you might have more luck?

Ben Root
--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Change in pcolor functionality from 0.99.1.1 to 1.0.0

2010-11-16 Thread Benjamin Root
On Mon, Nov 15, 2010 at 4:14 AM, Guy Griffiths
wrote:

>
> On Friday 12 Nov 2010 15:20:43 Ryan May wrote:
> > On Fri, Nov 12, 2010 at 8:40 AM, Benjamin Root  wrote:
> > > On Fri, Nov 12, 2010 at 5:11 AM, Guy Griffiths
> > > 
> > >
> > > wrote:
> > >> Hi,
> > >>
> > >> I've been using matplotlib for a while for plotting scientific data,
> and
> > >> recently upgraded from version 0.99.1.1 to 1.0.0.  Primarily I use
> > >> pcolor to
> > >> produce plots of concentration in 2D space.  I use reasonably fine
> > >> meshes, and
> > >> in v0.99.1.1 the output looked great.
> > >>
> > >> In v1.0.0, all of my plots (using the same code) have faint gridlines
> > >> visible.
> > >> Since the mesh I am using is quite fine, this makes the plots look
> > >> terrible
> > >> (i.e. more gridlines than actual data).  This seems to be controlled
> by
> > >> the
> > >> "edgecolors" keyword, but even when set to 'none' they are still
> there.
> > >>  Is
> > >> there any way to remove them completely without reverting back to
> > >> 0.99.1.1 (which I'd prefer not to do, since some of the API changes
> are
> > >> really useful
> > >> for creating very polished graphs suitable for publication)?
> > >>
> > >> imshow seems to have closer results to what I want (i.e. no
> gridlines),
> > >> but
> > >> with imshow, the axes denote the pixel position, and there is no
> option
> > >> to display on polar axes (which is essential).
> > >>
> > >> Any help would be much appreciated.
> > >>
> > >> Regards,
> > >>
> > >> Guy Griffiths
> > >
> > > Guy, I have noticed something similar a few months ago with pcolor, but
> I
> > > am not certain if it is the same problem as yours.  First, which
> backend
> > > are you using?  Second, are you seeing the grid lines in both the
> figure
> > > window and the saved output?  Also, what format are you saving your
> > > output to? Lastly, which pcolor function are you using (pcolor(),
> > > pcolormesh(), pcolorfast())?
> > >
> > > If you could include a screenshot or the saved file, I could see if it
> is
> > > similar to my problem.
> >
> > Yeah, I had noticed a problem with pcolor too. You can see the problem
> > I've been seeing here:
> >
> >
> http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_demo.html
> >
> > Calling pcolor with antialiased=False removes the lines, but that's
> > just a workaround, not a solution.  I'm not really sure where to start
> > to track this down, so if anyone has a suggestion, I'm all ears.
> >
> > Ryan
>
> Hi,
>
> Thanks for the help.  The problem I'm seeing is as Ryan describes (same
> effect
> as in the screenshot, but let me know if you still want me to provide an
> example), and appears in both the figure window and saved output (at least
> png
> and pdf).  The backend I am using is Qt/Agg.  I was using pcolor(), but it
> appears that pcolormesh() doesn't (always) have this problem.  Setting
> antialiased=False removes some of the problems.  In summary:
>
> pcolor(), antialiased=True - lines on screen, png, pdf
> pcolor(), antialiased=False - lines on pdf, fine on png/screen
> pcolormesh() - lines on pdf, fine on png/screen
>
> Regards,
>
> Guy
>

Guy,

I found my old bug report on this visual artifact.  Oddly enough, the
problem for me was with pcolormesh, not with pcolor.  There is a script
attached to the report that tests 4 combinations of function calls and
rasterized=True.  Could you see how it turns out for you?

Thanks,
Ben Root
--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Change in pcolor functionality from 0.99.1.1 to 1.0.0

2010-11-16 Thread Guy Griffiths

On Tuesday 16 Nov 2010 15:35:31 Benjamin Root wrote:
> On Mon, Nov 15, 2010 at 4:14 AM, Guy Griffiths
> 
> wrote:
> > On Friday 12 Nov 2010 15:20:43 Ryan May wrote:
> > > On Fri, Nov 12, 2010 at 8:40 AM, Benjamin Root  wrote:
> > > > On Fri, Nov 12, 2010 at 5:11 AM, Guy Griffiths
> > > > 
> > > > 
> > > > wrote:
> > > >> Hi,
> > > >> 
> > > >> I've been using matplotlib for a while for plotting scientific data,
> > 
> > and
> > 
> > > >> recently upgraded from version 0.99.1.1 to 1.0.0.  Primarily I use
> > > >> pcolor to
> > > >> produce plots of concentration in 2D space.  I use reasonably fine
> > > >> meshes, and
> > > >> in v0.99.1.1 the output looked great.
> > > >> 
> > > >> In v1.0.0, all of my plots (using the same code) have faint
> > > >> gridlines visible.
> > > >> Since the mesh I am using is quite fine, this makes the plots look
> > > >> terrible
> > > >> (i.e. more gridlines than actual data).  This seems to be controlled
> > 
> > by
> > 
> > > >> the
> > > >> "edgecolors" keyword, but even when set to 'none' they are still
> > 
> > there.
> > 
> > > >>  Is
> > > >> 
> > > >> there any way to remove them completely without reverting back to
> > > >> 0.99.1.1 (which I'd prefer not to do, since some of the API changes
> > 
> > are
> > 
> > > >> really useful
> > > >> for creating very polished graphs suitable for publication)?
> > > >> 
> > > >> imshow seems to have closer results to what I want (i.e. no
> > 
> > gridlines),
> > 
> > > >> but
> > > >> with imshow, the axes denote the pixel position, and there is no
> > 
> > option
> > 
> > > >> to display on polar axes (which is essential).
> > > >> 
> > > >> Any help would be much appreciated.
> > > >> 
> > > >> Regards,
> > > >> 
> > > >> Guy Griffiths
> > > > 
> > > > Guy, I have noticed something similar a few months ago with pcolor,
> > > > but
> > 
> > I
> > 
> > > > am not certain if it is the same problem as yours.  First, which
> > 
> > backend
> > 
> > > > are you using?  Second, are you seeing the grid lines in both the
> > 
> > figure
> > 
> > > > window and the saved output?  Also, what format are you saving your
> > > > output to? Lastly, which pcolor function are you using (pcolor(),
> > > > pcolormesh(), pcolorfast())?
> > > > 
> > > > If you could include a screenshot or the saved file, I could see if
> > > > it
> > 
> > is
> > 
> > > > similar to my problem.
> > > 
> > > Yeah, I had noticed a problem with pcolor too. You can see the problem
> > 
> > > I've been seeing here:
> > http://matplotlib.sourceforge.net/examples/pylab_examples/pcolor_demo.htm
> > l
> > 
> > > Calling pcolor with antialiased=False removes the lines, but that's
> > > just a workaround, not a solution.  I'm not really sure where to start
> > > to track this down, so if anyone has a suggestion, I'm all ears.
> > > 
> > > Ryan
> > 
> > Hi,
> > 
> > Thanks for the help.  The problem I'm seeing is as Ryan describes (same
> > effect
> > as in the screenshot, but let me know if you still want me to provide an
> > example), and appears in both the figure window and saved output (at
> > least png
> > and pdf).  The backend I am using is Qt/Agg.  I was using pcolor(), but
> > it appears that pcolormesh() doesn't (always) have this problem. 
> > Setting antialiased=False removes some of the problems.  In summary:
> > 
> > pcolor(), antialiased=True - lines on screen, png, pdf
> > pcolor(), antialiased=False - lines on pdf, fine on png/screen
> > pcolormesh() - lines on pdf, fine on png/screen
> > 
> > Regards,
> > 
> > Guy
> 
> Guy,
> 
> I found my old bug report on this visual artifact.  Oddly enough, the
> problem for me was with pcolormesh, not with pcolor.  There is a script
> attached to the report that tests 4 combinations of function calls and
> rasterized=True.  Could you see how it turns out for you?
> 
> Thanks,
> Ben Root

Ben,

I've run the script attached to the bug report.  The results I got were as 
follows:

PNG - Artifacts on both pcolor() plots, no artifacts on either pcolormesh() 
plot
PDF - Artifacts on pcolor() and pcolormesh() with rasterized=False.  Less 
obvious artifacts on pcolor() with rasterized=True.  No artifacts on 
pcolormesh() with rasterized=True
EPS - Artifacts on pcolor() with rasterized=True.  All others fine
SVG - Artifacts on pcolor() and pcolormesh() with rasterized=False.  More 
obvious artifacts on pcolor() with rasterized=True.  No artifacts on 
pcolormesh() with rasterized=True

Hope this is helpful.

Cheers,

Guy

--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.n

Re: [Matplotlib-users] plot polarization map (like ZEMAX)

2010-11-16 Thread Benjamin Root
On Sun, Nov 14, 2010 at 5:17 PM, Kornél Jahn  wrote:

> Hello,
> I would like to plot the polarization state of a two-dimensional vector
> field (linear, circular or generally elliptic), similarly to that seen on
> this ZEMAX plot:
> http://www.zemax.com/UserFiles/Image/UI/pol_pupil.gif
> It looks like some kind of enhanced quiver plot: a small line with arrows
> at both ends points out the local direction of linear polarization, while a
> directed ellipse with a given orientation of its axes depicts local
> elliptical polarization state (which becomes a circle for circular
> polarization).
>
> I am a novice matplotlib user, please give me some advice on how to start
> with implementing such a plot (what to read, API examples to look at etc.)
>
> Thanks,
> Kornel JAHN
>
>
Hmm, interesting idea.  quiver.py is certainly the right place to start, but
I think there is one key missing feature in matplotlib: I haven't a clue how
one would draw a arrow in an ellipse shape.

As far as I know, such an arrow style isn't possible.  What you could do
instead is to create a new class that is based on the ellipse collection
instead of the Quiver class.  Once you get just basic ellipses drawn, then
maybe you can add some lines to the ellipses to indicate the direction of
spin, much like how the barbs are drawn in the Barbs class.

I hope this is helpful.

Ben Root
--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Unknown projection '3d' even with svn version?

2010-11-16 Thread Eric Emsellem
Hi,

I have just installed the svn version of matplotlib and basemap + numpy from 
the 
svn repository of
http://download.opensuse.org/repositories/home:/ocefpaf/openSUSE_11.3/x86_64/

When I do:
===
ipython -pylab
(matplotlib 1.0.0, backend GTKAgg version 2.17.0, openSuse 11.3 x86_64)

import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

I get a

ValueError: Unknown projection '3d'

I did the upgrade to the svn version because the previous one (which was 
already 
1.0) gave me the same message...

what's wrong here?
(looked at the web and couldn't find out a good solution, beyond the upgrade I 
did)

thanks in advance
Eric


--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Unknown projection '3d' even with svn version?

2010-11-16 Thread Benjamin Root
On Tue, Nov 16, 2010 at 10:48 AM, Eric Emsellem  wrote:

> Hi,
>
> I have just installed the svn version of matplotlib and basemap + numpy
> from the
> svn repository of
>
> http://download.opensuse.org/repositories/home:/ocefpaf/openSUSE_11.3/x86_64/
>
> When I do:
> ===
> ipython -pylab
> (matplotlib 1.0.0, backend GTKAgg version 2.17.0, openSuse 11.3 x86_64)
>
> import numpy as np
> from mpl_toolkits.mplot3d import Axes3D
> import matplotlib.pyplot as plt
>
> fig = plt.figure()
> ax = fig.add_subplot(111, projection='3d')
> 
> I get a
>
> ValueError: Unknown projection '3d'
>
> I did the upgrade to the svn version because the previous one (which was
> already
> 1.0) gave me the same message...
>
> what's wrong here?
> (looked at the web and couldn't find out a good solution, beyond the
> upgrade I did)
>
> thanks in advance
> Eric
>
>
>
Eric,

Could you please execute the following:

import matplotlib
print matplotlib.__version__

and report back what it says?  I suspect that when you installed the svn
version, the original version of matplotlib is still getting loaded.  The
projection='3d' feature is brand new to 1.0.0.

Ben Root
--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Unknown projection '3d' even with svn version?

2010-11-16 Thread Benjamin Root
On Tue, Nov 16, 2010 at 11:24 AM, Eric Emsellem  wrote:

> Dear Ben
>
> thanks a lot for the quick reply.
>
> I did that (and read some posts on the web) but no luck, as it says:
>
> 1.0.0
>
> I in fact just went back to my openSuse 11.3 (Science repo) version because
> it went really wrong with scipy etc and I didn't want to mess up my setup.
> But still the same message with the Unknown projection.
>
> I have checked the axes3d.py in my mpl_toolkits and it has the "name =
> '3d'" at the beginning and the register at the end...
>
> ???
>
>
> Eric
>
>  Could you please execute the following:
>>
>> import matplotlib
>> print matplotlib.__version__
>>
>> and report back what it says?  I suspect that when you installed the svn
>> version, the original version of matplotlib is still getting loaded.
>> The projection='3d' feature is brand new to 1.0.0.
>>
>> Ben Root
>>
>

Strange indeed.  Ok, what does matplotlib.__file__ say?  Does the filename
match the path you are expecting?  At this point, I would also try putting
print statements in the register code at the end of axes3d.py to see if that
code path gets executed (can't see why not).

Ben Root
--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Unknown projection '3d' even with svn version?

2010-11-16 Thread Eric Emsellem
Dear Ben

thanks a lot for the quick reply.

I did that (and read some posts on the web) but no luck, as it says:

1.0.0

I in fact just went back to my openSuse 11.3 (Science repo) version because it 
went really wrong with scipy etc and I didn't want to mess up my setup. But 
still the same message with the Unknown projection.

I have checked the axes3d.py in my mpl_toolkits and it has the "name = '3d'" at 
the beginning and the register at the end...

???

Eric

> Could you please execute the following:
>
> import matplotlib
> print matplotlib.__version__
>
> and report back what it says?  I suspect that when you installed the svn
> version, the original version of matplotlib is still getting loaded.
> The projection='3d' feature is brand new to 1.0.0.
>
> Ben Root

--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How to get axes from a user click?

2010-11-16 Thread Nicolas Bigaouette
Hi all,

I have defined some shortcuts I often use using pylab.ginput(). I normally
do:

> fig = pylab.figure()

fig.canvas.mpl_connect('key_press_event', on_key)

with my "on_key" function being (simplified):

> def on_key(event):

if (event.key == 'q'):

sys.exit(0)

elif (event.key == 'w'):

pylab.close(pylab.gcf())

elif (event.key == 'd'):

print "Please click two points to get the distance and slope."

points = pylab.ginput(n=2, show_clicks=True)

[...]

pylab.plot([points[0][0], points[1][0]], [points[0][1],
> points[1][1]],  '+r', lw=1.0)

pylab.plot([points[0][0], points[1][0]], [points[0][1],
> points[1][1]],  '--r', lw=1.0)

pylab.draw()


I'm plotting two markers where the user clicked and a line between them.

This works fine, except when there is multiple subplots. I can correctly
select points and get their position, but the plot commands will put the
markers+line in the last subplot. I tried using "pylab.gca().plot()" but
gca() always returns the last axes.

My question is, how can I plot on the axes the user clicked on?

Thank you!

N
--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Update values of errorbars

2010-11-16 Thread Stan West
> From: Gianfranco Durin [mailto:g.du...@inrim.it] 
> Sent: Wednesday, November 10, 2010 11:32
> 
> Dear mpl users,
> I have the following problem to solve. Imagine to have the 
> simple example reported on website plotting the errorbars of 
> some x,y data:

...

> and if I change, for instance, y:
> 
> y = y/2.
> 
> I can easily replace the x,y with:
> 
> p[0].set_data(x,y)
> 
> but I do not know how to do the same for the errorbars.

I believe I see how you could do it.  The errorbar call returns the tuple p =
(plotline, caplines, barlinecols) [1], and to update the errorbars, you must
modify the objects in the caplines and barlinecols lists.  Each element of the
caplines list is a Line2D artist [2] for the left, right, top, or bottom caps;
you can use its methods set_data, set_xdata, or set_ydata to modify its
coordinates, as you did for the main line.  Each element of the barlinecols
list is a LineCollection [3] artist responsible for all of the x or y
errorbars; you can use the set_segments method to provide new coordinates.

[1]
http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.error
bar
[2]
http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.lines.Line2D
[3]
http://matplotlib.sourceforge.net/api/collections_api.html#matplotlib.collecti
ons.LineCollection


--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Since upgrading to SUSE 11.3 matplotlib simply craches with segfault

2010-11-16 Thread Kurt Mueller
Now I found a solution:


>From the Education Repository of openSuse:
"URL: http://download.opensuse.org/repositories/Education/openSUSE_11.3/";

Install the packages:
   - python-numpy
   - python-matplotlib

These two seems to work together.


Have a nice day
-- 
m...@problemlos.ch


--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to get axes from a user click?

2010-11-16 Thread Benjamin Root
On Tue, Nov 16, 2010 at 12:01 PM, Nicolas Bigaouette
wrote:

> Hi all,
>
> I have defined some shortcuts I often use using pylab.ginput(). I normally
> do:
>
>> fig = pylab.figure()
>
> fig.canvas.mpl_connect('key_press_event', on_key)
>
> with my "on_key" function being (simplified):
>
>> def on_key(event):
>
> if (event.key == 'q'):
>
> sys.exit(0)
>
> elif (event.key == 'w'):
>
> pylab.close(pylab.gcf())
>
> elif (event.key == 'd'):
>
> print "Please click two points to get the distance and slope."
>
> points = pylab.ginput(n=2, show_clicks=True)
>
> [...]
>
> pylab.plot([points[0][0], points[1][0]], [points[0][1],
>> points[1][1]],  '+r', lw=1.0)
>
> pylab.plot([points[0][0], points[1][0]], [points[0][1],
>> points[1][1]],  '--r', lw=1.0)
>
> pylab.draw()
>
>
> I'm plotting two markers where the user clicked and a line between them.
>
> This works fine, except when there is multiple subplots. I can correctly
> select points and get their position, but the plot commands will put the
> markers+line in the last subplot. I tried using "pylab.gca().plot()" but
> gca() always returns the last axes.
>
> My question is, how can I plot on the axes the user clicked on?
>
> Thank you!
>
>
While this isn't in the same approach you were going, you could continue to
use mpl_connect instead of ginput.  If you create connections (and properly
disconnect as well) 'button_press_event' and 'button_release_event', you can
then utilize the event.inaxes property of the event object.  This has an
added advantage of making sure that the mouse click events are inside the
axes.

Another approach might be to find out the bbox's of all the subplot axes and
see if a coordinate falls inside any of those.

Ben Root
--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] psd (and friends) scaling and NFFT

2010-11-16 Thread Ryan May
Hi,

I spent a fair amount of time today debugging what I thought was a bug
in the scaling of psd() when I was using NFFT to specify zero-padding.
 This was a mis-use of the code on my part, where I should have been
using pad_to to get zero-padding. Most embarassing about this is that
I'm basically the maintainer of record for this code and responsible
for the most recent changes, part of which improved 0-padding. (> 2
years ago)

I've come to the conclusion that if I was able to get it wrong, it's
likely that this issue has bitten and will bite other users. The
problem stems from the fact that the code underlying psd (and csd,
etc.) will gladly pad your data to NFFT if len(x) < NFFT. The extra
0's added here throw off the scaling (whereas using pad_to does not).
[Aside for the curious: The NFFT-padding code pre-dates the use of
pad_to for zero-padding and was left so-as not to break code, not
realizing that leaving it was still wrong.]  Options:

1) Rip out the code that does the zero-padding based on NFFT and raise
an exception in the case that len(x) < NFFT.
2) Issue a warning on len(x) < NFFT for awhile, and then rip it out.
3) ?

I'm really tempted to just go with 1), with an exception that details
the problem and the fix. While this would break existing code, this
code is almost 100% guaranteed to be broken and silently producing the
incorrect answer (unless code was already hacking around our
broken-ness, which wouldn't be easy.)

I still need to go through and convince myself that there's not some
use-case where NFFT > len(x) would produce correct and desired
behavior, which isn't covered by pad_to. What I'm looking for is
thoughts from devs on breaking backwards compatibility and from users,
whose code may or may not be broken by such a change.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users