[Matplotlib-users] Event handling
Hi all, Is it possible to restrict the mouse movements to the points of a graph (curve tracking) ? So far I am able to obtain the location of the mouse in data coordinates if the mouse is over an axes. A code snippet is attached. Thanks in advance. Nils from pylab import plot, show, connect, xlabel, ylabel, legend, xlim, ylim from numpy import linspace, sin, pi, empty def find_minima(x): minima = empty((len(x),),dtype=bool) dx=x[1:]-x[:-1] minima[1:-1]=(dx[:-1]=0) (dx[1:]=0) #handle endpoint s # minima[0]=dx[0]=0 # minima[-1]=dx[-1]=0 return minima x = linspace(0,3*pi,200) y = sin(x) plot(x,y,'r.',label=r'$\sin(x)$') minima = find_minima(-y) plot(x[minima],y[minima],'ko',label='maxima') legend() def on_move(event): # # Connect to the mouse move event and print the location of the mouse # in data coordinates if the mouse is over an axes # x,y = event.x, event.y if event.inaxes: print 'data coords', event.xdata, event.ydata #connect('motion_notify_event', on_move) def click(event): x,y = event.x, event.y if event.inaxes: print 'you clicked', event.xdata, event.ydata connect('button_press_event',click) xlim(0,3*pi+0.1) ylim(-1.1,1.1) show() -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] bug with installation from KUBUNTU aptitude
hi matplotlib developers and users, let me inform you about the bug: when I use sudo aptitude install python-matplotlib it downloads LOTS of auxilary packages (IIRC about 200 MB for download and 400 MB for HDD after unpack, or kind of), still it doesn't work after installation, it yields ImportError: No module named _tkinter, please install the python-tk package when I install python-tk (1.7 MB for download, very small size in comparison with those 400 MB), all works OK. I hope you will have it fixed. Regards, Dmitrey -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] building from source on Windows
Hello Patrick, Thanks for reply! I didn't catch on the first email you were trying to build for python2.6. I haven't been able to get matplotlib to build correctly with python2.6. I'm actually curious as to how you were able to build matplotlib using the win32_static folder since it doesn't contain the libs and header files for tcl/tk 8.5 which python2.6 is build against. I didn't do anything really, except I have had installed Python 2.5 on the same system before. Maybe this left DLLs lying around and the compiled matplotlib uses those old DLLs? This was the original error for me and I had to modify the setupext.py to look for the tcl/tk 8.5 includes (which I had to manually add to win32_static). What happens if you try: import matplotlib.pyplot as plt x = range(0,100) y = range(0,100) plt.plot(x,y) plt.show() I have used win32_static_vs (I have VC++ 9.0 installed) and it just worked! It displayed the graph and everything. As for the error you specifically mentioned, have you checked to make sure that the correct dll exists? This error typically happens to me when the dll didn't build properly (if at all). How do I do that? After this successful build, I can't find any DLL in the 'build' folder. I have unpacked matplotlib-0.98.5.2.win32-py2.6.exe installer and it doesn't contain any dll either. Regards, mk -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] RuntimeError: maximum recursion depth exceeded while calling a Python object
Hello everyone, It's fine when I plot in interactive Python shell like so: import matplotlib.pyplot as plt plt.plot(valist) plt.show() However, I get an exception like in subject when I call it from function: def plotit(origlist, valist): plt.plot(origlist) plt.plot(valist) plt.show() (origlist and valist are lists of small floats, each 256 elems long) The exception: Traceback (most recent call last): File C:\Python26\loadavg3.py, line 115, in module plotit(origlist, valist) File C:\Python26\loadavg3.py, line 102, in plotit plt.plot(origlist) File C:\Python26\Lib\site-packages\matplotlib\pyplot.py, line 2096, in plot ret = gca().plot(*args, **kwargs) File C:\Python26\Lib\site-packages\matplotlib\axes.py, line 3277, in plot for line in self._get_lines(*args, **kwargs): File C:\Python26\Lib\site-packages\matplotlib\axes.py, line 389, in _grab_next_args for seg in self._plot_1_arg(remaining[0], **kwargs): File C:\Python26\Lib\site-packages\matplotlib\axes.py, line 243, in _plot_1_arg x, y, multicol = self._xy_from_y(y) File C:\Python26\Lib\site-packages\matplotlib\axes.py, line 199, in _xy_from_y b = self.axes.yaxis.update_units(y) File C:\Python26\Lib\site-packages\matplotlib\axis.py, line 939, in update_units converter = munits.registry.get_converter(data) File C:\Python26\Lib\site-packages\matplotlib\units.py, line 137, in get_converter converter = self.get_converter( thisx ) File C:\Python26\Lib\site-packages\matplotlib\units.py, line 137, in get_converter converter = self.get_converter( thisx ) File C:\Python26\Lib\site-packages\matplotlib\units.py, line 137, in get_converter (snip lots of identical lines) converter = self.get_converter( thisx ) File C:\Python26\Lib\site-packages\matplotlib\units.py, line 137, in get_converter converter = self.get_converter( thisx ) File C:\Python26\Lib\site-packages\matplotlib\units.py, line 133, in get_converter if isinstance(x, np.ndarray) and x.dtype != np.object: RuntimeError: maximum recursion depth exceeded while calling a Python object Regards, mk -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] unfilled markers?
Before my work in 2004, the colors were not following the line color at all, which was clearly bad behavior. Now, there are two categories: filled markers (with edge color black and filling following the line color) and non-filled markers (with edge color following line color). The black edge of filled markers is a matter of style which I personally like and would not want to change. The thing that was up for dispute was only about what the edge color of filled markers should do when the filling is switched off. I see three ways to solve this: a) Leave it black. (current behavior) b) Switch mec to line color if mfc is either none or white. c) Switch mec to line color if mfc is not auto b) or c) might be what people would expect and prefer, but I feared that it would be one step too many in built-in intelligence. But then - maybe c) would be ok? After all, switching from c) to a) by an explicit mec=k is simple and obvious, the other way around takes a bit more. Greetings, Norbert Gary Ruben wrote: Thanks John, That shows how long it is since I used line markers in my plots. Because I use them so infrequently, I'm probably not the best one to suggest it, but I think it would be nicer for the default colour to match the line colour by default, or for an option to be added to allow its simple selection without users having to search through the mailing list to find Norbert's solution. If I was publishing a colour plot with line markers I would definitely want to do this. Gary John Hunter wrote: On Mon, Jan 26, 2009 at 6:17 AM, Gary Ruben wrote: Has the mec always been black? I thought it used to be the same as the line colour. I expected it to default to the line colour, as Che expected. It's been this way since at least 2004: http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/lib/matplotlib/__init__.py?revision=540view=markup JDH -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] RuntimeError: maximum recursion depth exceeded while calling a Python object
Hello everyone, Forget it, I was mistakenly passing a list of dictionaries to the pyplot function instead of passing a list of extracted values. Regards, mk -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] bug with installation from KUBUNTU aptitude
Dmitrey ha scritto: hi matplotlib developers and users, let me inform you about the bug: when I use sudo aptitude install python-matplotlib it downloads LOTS of auxilary packages (IIRC about 200 MB for download and 400 MB for HDD after unpack, or kind of), still it doesn't work after installation, it yields ImportError: No module named _tkinter, please install the python-tk package when I install python-tk (1.7 MB for download, very small size in comparison with those 400 MB), all works OK. This is a dependency bug of the Kubuntu packaging system. It is most probably unrelated to Matplotlib upstream developement. You should report it to the Kubuntu bugzilla (after having looked if it has already been filed). By the way, the LOTS of ausiliary packages are most probably as needed as python-tk to make it work. Don't really understand what you mean by those kind of comparisons, but all complex packages have dependencies. It just seems Kubuntu missed one. Thanks, Massimo -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] building from source on Windows
John Hunter wrote: It might help if you recursively remove the buld directory, do a clean rebuld, capture the build output in a file, and post that here so we can see if we can get an idea what is going on Since it's over 250kB, I pasted it here: http://pastebin.com/f466bd0db Regards, mk -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] setting line parameters like color, lw, etc
Hello everyone, Got it now, plot() apparently returns a list and I have to unpack it, I feel silly now... Regards, mk -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] setting line parameters like color, lw, etc
Hello everyone, Newbie alert. How do I set the attributes of Line2D instance? I have: origline = plt.plot(origlist) valine = plt.plot(valist) plt.xlim(0,256) valine.set_color('r') valine.set_linewidth(2) I get: Traceback (most recent call last): File C:/Python26/loadavg2.py, line 121, in module plotit(valist, smalist) File C:/Python26/loadavg2.py, line 106, in plotit valine.set_color('r') AttributeError: 'list' object has no attribute 'set_color' WTF?? After all, Line2D api docs, e.g. http://matplotlib.sourceforge.net/api/artist_api.html#matplotlib.lines.Line2D.set_color clearly state there is set_color method to the Line2D instance! I get the same error with get_* methods. Regards, mk -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] building from source on Windows
On Tue, Jan 27, 2009 at 4:31 AM, Marcin Krol mrk...@gmail.com wrote: Hello Patrick, Thanks for reply! I didn't catch on the first email you were trying to build for python2.6. I haven't been able to get matplotlib to build correctly with python2.6. I'm actually curious as to how you were able to build matplotlib using the win32_static folder since it doesn't contain the libs and header files for tcl/tk 8.5 which python2.6 is build against. I didn't do anything really, except I have had installed Python 2.5 on the same system before. Maybe this left DLLs lying around and the compiled matplotlib uses those old DLLs? This was the original error for me and I had to modify the setupext.py to look for the tcl/tk 8.5 includes (which I had to manually add to win32_static). What happens if you try: import matplotlib.pyplot as plt x = range(0,100) y = range(0,100) plt.plot(x,y) plt.show() I have used win32_static_vs (I have VC++ 9.0 installed) and it just worked! It displayed the graph and everything. As for the error you specifically mentioned, have you checked to make sure that the correct dll exists? This error typically happens to me when the dll didn't build properly (if at all). How do I do that? After this successful build, I can't find any DLL in the 'build' folder. I have unpacked matplotlib-0.98.5.2.win32-py2.6.exe installer and it doesn't contain any dll either. It might help if you recursively remove the buld directory, do a clean rebuld, capture the build output in a file, and post that here so we can see if we can get an idea what is going on -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Event handling
On Tue, Jan 27, 2009 at 2:15 AM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: Hi all, Is it possible to restrict the mouse movements to the points of a graph (curve tracking) ? No, but you can obtain the vertices of the line that are within a tolerance of the clicked point using the picking functions. See the tutorial at http://matplotlib.sourceforge.net/users/event_handling.html and the pick* demos at http://matplotlib.sourceforge.net/examples/event_handling/index.html JDH -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Fwd: Event handling
---BeginMessage--- Please respond on list and I, or someone else, will try and respond. On Tue, Jan 27, 2009 at 7:08 AM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: On Tue, 27 Jan 2009 06:37:09 -0600 John Hunter jdh2...@gmail.com wrote: On Tue, Jan 27, 2009 at 2:15 AM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: Hi all, Is it possible to restrict the mouse movements to the points of a graph (curve tracking) ? No, but you can obtain the vertices of the line that are within a tolerance of the clicked point using the picking functions. See the tutorial at http://matplotlib.sourceforge.net/users/event_handling.html and the pick* demos at http://matplotlib.sourceforge.net/examples/event_handling/index.html JDH Hi John, Thank you very much for your response. The horizontal distance between consecutive points is 5. in my application. Is the value of picker linked to the distance ? I mean How should I use picker to circumvent multiple results ? Cheers, Nils ---End Message--- -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Fwd: Event handling
On Tue, Jan 27, 2009 at 8:18 AM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: Thank you very much for your response. The horizontal distance between consecutive points is 5. in my application. Is the value of picker linked to the distance ? I mean How should I use picker to circumvent multiple results ? The scalar value of the picker is a epsilon tolerance in points (1 point = 1/72 inches) so you will need to set this distance to be small enough to only overlap one point when you click. If you want to only return a single point, you can write a custom picker function to return only the point closest to the click point. JDH -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] building from source on Windows
On Tue, Jan 27, 2009 at 7:09 AM, Marcin Krol mrk...@gmail.com wrote: John Hunter wrote: It might help if you recursively remove the buld directory, do a clean rebuld, capture the build output in a file, and post that here so we can see if we can get an idea what is going on Since it's over 250kB, I pasted it here: http://pastebin.com/f466bd0db First of all, on the clean build, when you do import matplotlib._path do you still get the same error. I don't know a ton about windows and even less about visual studio, but according to the build output you posted a _path.pyd file is built and apparently installed. It may be that it is trying to linking against some dll that is not on your system. There is a windows freeware program I used to use to debug this stuff, in which you could load the pyd file and see what it links against, which reported failures. Perhaps a windows guru can advise here. In the past, there was a bug in distutils that was forcing the compiler to link against msvcp71.dll which could be fixed by patching distutils. Don't know if this is related -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] building from source on Windows
John Hunter wrote: First of all, on the clean build, when you do import matplotlib._path do you still get the same error. No, it's working fine on the new build (the import above and the whole installation0 -- once I switched to VC++ from MinGW. snip info, ack Regards, mk -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Fwd: Event handling
On Tue, 27 Jan 2009 08:57:17 -0600 John Hunter jdh2...@gmail.com wrote: On Tue, Jan 27, 2009 at 8:18 AM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: Thank you very much for your response. The horizontal distance between consecutive points is 5. in my application. Is the value of picker linked to the distance ? I mean How should I use picker to circumvent multiple results ? The scalar value of the picker is a epsilon tolerance in points (1 point = 1/72 inches) so you will need to set this distance to be small enough to only overlap one point when you click. If you want to only return a single point, you can write a custom picker function to return only the point closest to the click point. Unfortunately, I am not sure how to implement a custom picker function. Any pointer would be appreciated. Thanks in advance. Nils -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Fwd: Event handling
On Tue, Jan 27, 2009 at 9:27 AM, Nils Wagner nwag...@iam.uni-stuttgart.de wrote: If you want to only return a single point, you can write a custom picker function to return only the point closest to the click point. Unfortunately, I am not sure how to implement a custom picker function. Any pointer would be appreciated. The example I pointed you to in my first post has an example of a custom picker function. It is in the section labelled picking with a custom hit test function http://matplotlib.sourceforge.net/examples/event_handling/pick_event_demo.html We've taken a lot of time to write the documentation and examples. When you ask us questions on the mailing list and we point you to documentation and examples, please take the time to read them. One reason we wrote them is so that we would not have to continuously solve the same problems over and over again on the mailing list. I'm happy to help if you find the documentation or examples confusing, but it will serve us both if you spend some time trying to digest them. JDH -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] building from source on Windows
I figured out why your show() works...you had WxPython installed and I'm assuming your backend was defaulting to this since Tkinter wasn't found. Once I noticed that I installed WxPython and then re-buily matplotlib with WxPython. If I used wxpython as my backend, then my GUIs worked. I can import pylab just fine and I don't appear to have any errors. While I can't figure out what your problem is, you are free to try the binary I built and see if it works: http://code.patricktmarsh.com/matplotlib-0.98.6svn.win32-py2.6.exe If you do decide to try this, let me know if it works. -Patrick On Tue, Jan 27, 2009 at 9:22 AM, Marcin Krol mrk...@gmail.com wrote: John Hunter wrote: First of all, on the clean build, when you do import matplotlib._path do you still get the same error. No, it's working fine on the new build (the import above and the whole installation0 -- once I switched to VC++ from MinGW. snip info, ack Regards, mk -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Patrick Marsh Graduate Research Assistant School of Meteorology University of Oklahoma http://www.patricktmarsh.com -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] unfilled markers?
Hi Norbert, Both of your proposals (b) and (c) sound better to me than the current behaviour, although they don't sound as obvious to me as simply defaulting to always setting the mec to the line colour unless overridden using mec=k - you could label this proposal (d). Since others seem to have been happy with the black edges and I don't know how much extra logic (and consequently extra overhead) is required to change to (d), I'd be easily persuaded that (b) or (c) would be OK since, as you say, the black edge of filled markers is a matter of style preference and if black edges are not wanted on a particular plot that uses filled markers, the edge width can simply be set to zero. The decision might be guided by whichever results in the simplest logic or least overhead. regards, Gary Norbert Nemec wrote: Before my work in 2004, the colors were not following the line color at all, which was clearly bad behavior. Now, there are two categories: filled markers (with edge color black and filling following the line color) and non-filled markers (with edge color following line color). The black edge of filled markers is a matter of style which I personally like and would not want to change. The thing that was up for dispute was only about what the edge color of filled markers should do when the filling is switched off. I see three ways to solve this: a) Leave it black. (current behavior) b) Switch mec to line color if mfc is either none or white. c) Switch mec to line color if mfc is not auto b) or c) might be what people would expect and prefer, but I feared that it would be one step too many in built-in intelligence. But then - maybe c) would be ok? After all, switching from c) to a) by an explicit mec=k is simple and obvious, the other way around takes a bit more. Greetings, Norbert -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] legend for plots with points
mfabulous wrote: Hi all, I apologize if this was asked before. I just started adding legends to my plots and found the legend stile for a point-plot, i.e. a plot using points rather than lines to be a bit confusing. Example: pylab.plot(arange(5), arange(5), 'o', label=foo) pylab.legend() Will produce a legend which looks like o o foo. Why are there two points? Can I force it to give me only one? That may depend on how old your version of matplotlib is; for quite a while there has been a numpoints kwarg to the legend command which lets you set that number, e.g., pylab.legend(numpoints=1). Eric -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] legend for plots with points
mfabulous wrote: Hi all, I apologize if this was asked before. I just started adding legends to my plots and found the legend stile for a point-plot, i.e. a plot using points rather than lines to be a bit confusing. Example: pylab.plot(arange(5), arange(5), 'o', label=foo) pylab.legend() Will produce a legend which looks like o o foo. Why are there two points? Can I force it to give me only one? That may depend on how old your version of matplotlib is; for quite a while there has been a numpoints kwarg to the legend command which lets you set that number, e.g., pylab.legend(numpoints=1). Eric Thats it... thank you! Cheers, Maximilian -- View this message in context: http://www.nabble.com/legend-for-plots-with-points-tp21680968p21689742.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Tutorial on working with Excel files in Python(without COM and cross platform!) at PyConUS 2009
Derek Hohls wrote: I hope I speak for others when I say: for those of us who cannot be at PyCon, please consider making tutorials etc available for download afterwards. We'd love to be able to spread the good word about these excellent libraries. Keep an eye out on the PyConUS website after the conference, I believe they'll make the tutorials available there... cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] setting line parameters like color, lw, etc
Le mardi 27 janvier 2009 à 13:17 +0100, Marcin Krol a écrit : How do I set the attributes of Line2D instance? I have: origline = plt.plot(origlist) valine = plt.plot(valist) plt.xlim(0,256) valine.set_color('r') valine.set_linewidth(2) Traceback (most recent call last): AttributeError: 'list' object has no attribute 'set_color' As mentioned in the traceback, valine is a list and not a Line2D instance. In fact, the plt.plot function returns the list of the Line2D instances added to the axes by the instruction. Even if you only plot one curve. As a solution, you may correct to valine, = plt.plot(valist) which unpack the list and extract the first item (the Line2D instance you want) to valine. -- Fabrice Silva si...@lma.cnrs-mrs.fr LMA UPR CNRS 7051 - équipe S2M -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] bug with installation from KUBUNTU aptitude
massimo sandal wrote: Dmitrey ha scritto: hi matplotlib developers and users, after installation, it yields ImportError: No module named _tkinter, please install the python-tk package all complex packages have dependencies. It just seems Kubuntu missed one. Maybe, Maybe not -- MPL is perfectly usable without tk -- you just can't use the tk back-end. If someone is going to use it with GTK, or wx, or to generate images for a web app, they don't need TK, for instance, and may not want it installed. However, it looks like MPL is setting TK as the default back-end, so maybe TK should be a dependency if they're doing that. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception chris.bar...@noaa.gov -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] zeros on log scatter plot
Hi, I am creating a scatter plot of some data that spans many orders of magnitude, and so I am changing the axes using gca().set_xscale('log') gca().set_yscale('log') Clearly, this only shows non-zero data. Is there an easy way to also include data has zero values for coordinates (say one tick mark to the left/below)? Thanks in advance! Uri -- Uri Laserson PhD Candidate, Biomedical Engineering Harvard Medical School (Genetics) Massachusetts Institute of Technology (Mathematics) phone +1 917 742 8019 laser...@mit.edu -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Running matplotlib
Dear All, I apologise if this is naive, but I am having problems with matplotlib. I downloaded it as a tar ball from SourceForge and it all compiled and installed without any error. I have the following setup. Download source SourceForge - matplotlib-0.98.5.2.tar.gz OS OpenSUSE 11.1 gcc gcc version 4.3.2 [gcc-4_3-branch revision 141291] (SUSE Linux) uname -a Linux trevor 2.6.27.7-9-pae #1 SMP 2008-12-04 18:10:04 +0100 i686 i686 i386 GNU/Linux python Python 2.6 matplotlib import matplotlib; print matplotlib.__version__ 0.98.5.2 I have taken the default 'matplotlibrc' from the web site and it is stored in ~/.matplotlib The problem I have is then when I issue the following from pylab import * Traceback (most recent call last): File stdin, line 1, in module File /usr/local/lib/python2.6/site-packages/pylab.py, line 1, in module File /usr/local/lib/python2.6/site-packages/matplotlib/pylab.py, line 206, in module File /usr/local/lib/python2.6/site-packages/matplotlib/mpl.py, line 1, in module File /usr/local/lib/python2.6/site-packages/matplotlib/artist.py, line 5, in module File /usr/local/lib/python2.6/site-packages/matplotlib/transforms.py, line 34, in module ImportError: No module named _path Any suggestions will be greatly appreciated, thanks Peter -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] unfilled markers?
It just occurred to me that another option might be to simply add a new colour option line for mec and mfc which would instruct them to pick up the current line colour. Gary -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Running matplotlib
The problem I have is then when I issue the following from pylab import * Traceback (most recent call last): File stdin, line 1, in module File /usr/local/lib/python2.6/site-packages/pylab.py, line 1, in module File /usr/local/lib/python2.6/site-packages/matplotlib/pylab.py, line 206, in module File /usr/local/lib/python2.6/site-packages/matplotlib/mpl.py, line 1, in module File /usr/local/lib/python2.6/site-packages/matplotlib/artist.py, line 5, in module File /usr/local/lib/python2.6/site-packages/matplotlib/transforms.py, line 34, in module ImportError: No module named _path I have resolved it. The problem was the protection on the .so files. They were installed with -rwxrwx--- which I changed to -rwxrwxrwx. I can now plot. Peter -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] contour coordinates
Hello, I am trying to extract the coordinates of contour lines. I tried the following: cs = *contour*(Z) for lev, col in zip(cs.levels, cs.collections): s = col._segments that I found in a previous post (title contouring, by Jose Gómez-Dans-2http://www.nabble.com/user/UserProfile.jtp?user=30071 Nov 30, 2007; 07:47am ) . I hoped that s will be a list of numpy arrays, each containing the (x,y) vertices defining a contour line at level lev. However, I got an error message: AttributeError: 'LineCollection' object has no attribute '_segments' How is it possible to get coordinates of the contours, similar to the MATLAB command [C,H] = *CONTOUR*(...) where the result in C is the coordinates of the contours. A similar question appeared in a post contour data (by Albert Swarthttp://www.nabble.com/user/UserProfile.jtp?user=382945 May 17, 2006; 09:42am) but I could not understand the answer. Is it possible to get more specific directions with a simple example ? Thanks Eli -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour coordinates
Eli Brosh wrote: Hello, I am trying to extract the coordinates of contour lines. I tried the following: cs = *contour*(Z) for lev, col in zip(cs.levels, cs.collections): s = col._segments that I found in a previous post (title contouring, by Jose Gómez-Dans-2 http://www.nabble.com/user/UserProfile.jtp?user=30071 Nov 30, 2007; 07:47am ) . I hoped that s will be a list of numpy arrays, each containing the (x,y) vertices defining a contour line at level lev. However, I got an error message: AttributeError: 'LineCollection' object has no attribute '_segments' How is it possible to get coordinates of the contours, similar to the MATLAB command [C,H] = *CONTOUR*(...) where the result in C is the coordinates of the contours. A similar question appeared in a post contour data (by Albert Swart http://www.nabble.com/user/UserProfile.jtp?user=382945 May 17, 2006; 09:42am) but I could not understand the answer. Is it possible to get more specific directions with a simple example ? Thanks Eli Eli: Calling get_paths() on each line collection in CS.collections will return a list of Path objects. From the Path objects, you can get a Nx2 array of vertices from the vertices attribute. There are no examples that I know of, but if you get it to do what you want to do, it would be great if you could contribute an example. As you noted, this question has come up several times before. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX: (303)497-6449 NOAA/OAR/PSD R/PSD1Email : jeffrey.s.whita...@noaa.gov 325 BroadwayOffice : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour coordinates
On Tue, Jan 27, 2009 at 5:33 PM, Jeff Whitaker jsw...@fastmail.fm wrote: Eli Brosh wrote: Hello, I am trying to extract the coordinates of contour lines. I tried the following: cs = *contour*(Z) for lev, col in zip(cs.levels, cs.collections): s = col._segments that I found in a previous post (title contouring, by Jose Gómez-Dans-2 http://www.nabble.com/user/UserProfile.jtp?user=30071 Nov 30, 2007; 07:47am ) . I hoped that s will be a list of numpy arrays, each containing the (x,y) vertices defining a contour line at level lev. However, I got an error message: AttributeError: 'LineCollection' object has no attribute '_segments' How is it possible to get coordinates of the contours, similar to the MATLAB command [C,H] = *CONTOUR*(...) where the result in C is the coordinates of the contours. A similar question appeared in a post contour data (by Albert Swart http://www.nabble.com/user/UserProfile.jtp?user=382945 May 17, 2006; 09:42am) but I could not understand the answer. Is it possible to get more specific directions with a simple example ? Thanks Eli Eli: Calling get_paths() on each line collection in CS.collections will return a list of Path objects. From the Path objects, you can get a Nx2 array of vertices from the vertices attribute. There are no examples that I know of, but if you get it to do what you want to do, it would be great if you could contribute an example. As you noted, this question has come up several times before. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX: (303)497-6449 NOAA/OAR/PSD R/PSD1Email : jeffrey.s.whita...@noaa.gov 325 BroadwayOffice : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users I'm not sure if this is entirely what you (Eli) are looking for, but I have code that will contour model data on a map and then extract the lat,lon pairs of all the vertices. If this is what you are looking for, I'm happy to share what I've done. -Patrick -- Patrick Marsh Graduate Research Assistant School of Meteorology University of Oklahoma http://www.patricktmarsh.com -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour coordinates
On Tue, Jan 27, 2009 at 7:16 PM, Eli Brosh ebro...@gmail.com wrote: Many thanks to Jeff and to Patric ! I will try to work along the line suggested by Jeff. Patric, please send me your code. I hope to learn from it. Thanks again, Eli Here is a template that can be used. I use this for meteorological models, but should work with any gridded file. import numpy as np from mpl_toolkits.basemap import Basemap f = (some gridded file) X = np.array(grab longitudes from f) Y = np.array(grab latitudes from f) field = np.array(grab field to be contoured from f) map = Basemap(make a Basemap call here) level = np.arange(minval, maxval, interval) col = map.contour(X, Y, field, level).collections for vertex in col[i].get_paths():# GET THE PATHS FOR THE EACH CONTOUR BY LOOPING THROUGH CONTOURS for vertex in xy.vertices: # ITERATE OVER THE PATH OBJECTS x, y = map(vertex[0],vertex[1],inverse=True) # vertex[0] and now 'x' is the longitude of the vertex and vertex[1] and now 'y' is the latitude of the vertex Let me know how this works. -Patrick On Tue, Jan 27, 2009 at 7:09 PM, Patrick Marsh patrickmars...@gmail.com wrote: On Tue, Jan 27, 2009 at 5:33 PM, Jeff Whitaker jsw...@fastmail.fm wrote: Eli Brosh wrote: Hello, I am trying to extract the coordinates of contour lines. I tried the following: cs = *contour*(Z) for lev, col in zip(cs.levels, cs.collections): s = col._segments that I found in a previous post (title contouring, by Jose Gómez-Dans-2 http://www.nabble.com/user/UserProfile.jtp?user=30071 Nov 30, 2007; 07:47am ) . I hoped that s will be a list of numpy arrays, each containing the (x,y) vertices defining a contour line at level lev. However, I got an error message: AttributeError: 'LineCollection' object has no attribute '_segments' How is it possible to get coordinates of the contours, similar to the MATLAB command [C,H] = *CONTOUR*(...) where the result in C is the coordinates of the contours. A similar question appeared in a post contour data (by Albert Swart http://www.nabble.com/user/UserProfile.jtp?user=382945 May 17, 2006; 09:42am) but I could not understand the answer. Is it possible to get more specific directions with a simple example ? Thanks Eli Eli: Calling get_paths() on each line collection in CS.collections will return a list of Path objects. From the Path objects, you can get a Nx2 array of vertices from the vertices attribute. There are no examples that I know of, but if you get it to do what you want to do, it would be great if you could contribute an example. As you noted, this question has come up several times before. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX: (303)497-6449 NOAA/OAR/PSD R/PSD1Email : jeffrey.s.whita...@noaa.gov 325 BroadwayOffice : Skaggs Research Cntr 1D-113 Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users I'm not sure if this is entirely what you (Eli) are looking for, but I have code that will contour model data on a map and then extract the lat,lon pairs of all the vertices. If this is what you are looking for, I'm happy to share what I've done. -Patrick -- Patrick Marsh Graduate Research Assistant School of Meteorology University of Oklahoma http://www.patricktmarsh.com -- Patrick Marsh Graduate Research Assistant School of Meteorology University of Oklahoma http://www.patricktmarsh.com -- This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users