Re: [Matplotlib-users] histogram and a line
You need to specify the ylim because your height may be larger than your histogram and then you cannot see it. Here is a script that reproduce your screenshot (with random data). import numpy as np import matplotlib.pyplot as plt plt.rc('xtick', direction = 'out') plt.rc('ytick', direction = 'out') data = np.random.normal(0,1,100) fig = plt.figure(figsize=(8,6), dpi=72, facecolor='w') axes = plt.subplot(111) axes.axvline(np.mean(data), 0, data.max(), linewidth=2, color='red') axes.hist(data, bins=50, normed=True) axes.set_ylim(0, 1) axes.set_xlim(-3, 3) axes.spines['right'].set_color('none') axes.spines['top'].set_color('none') axes.xaxis.set_ticks_position('bottom') axes.spines['bottom'].set_position(('data', -0.05)) axes.yaxis.set_ticks_position('left') axes.spines['left'].set_position(('data',-3.25)) plt.show() Nicolas On Mar 8, 2012, at 7:54 , Mic wrote: Hi Jerzy, Thank you for your answer. With the code below I get only a green line (see attached line.png): import numpy as np import matplotlib.pyplot as plt hist_data = [] heigth = max(hist_data) + 10 mean = np.mean(hist_data) f = plt.figure() h = f.add_subplot(111) h.hist(hist_data, bins=50, normed=True) h.plot([mean,mean],[0,height]) f.savefig('myhist.png') without h.plot() I get a histogram (see attached matplot_hist.png). How can I get the line and the histogram at the same time in the picture? How is it possible to norm the vertical axis in order to get similar results like in this picture (see attached hist.png)? Thank you in advance. On Wed, Mar 7, 2012 at 6:41 PM, Jerzy Karczmarczuk jerzy.karczmarc...@unicaen.fr wrote: Mic: Hello, I am able to draw a histogram with the following code: ... h.hist(hist_data, bins=50, normed=True) However, I don't know how to draw a line for median at 249 position like in attachment. Are your axes really matplotlib axes? (I have doubts, since the vertical is not normed, although your histogram is). In your real axes, the command plot([249,249],[0,height]) draws a vertical line (there is a primitive vert. line as well), what is the problem?? Jerzy Karczmarczuk -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users line.pngmatplot_hist.pnghist.png-- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Has nxutils been removed from mpl?
Benjamin Root ben.root@... writes: snip Essentially, you make a Path object using the vertices, and then use its contains_point() method. Ben Root OK, but given that contains_point works with a *single* point at a time, I have to call it for all my points which is a bit more cumbersome, or am I missing something? Jorge -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] pylab TclError: out of stack space - tkinter?
Hi, first time I'm posting here. I'm fairly new to using pylab, and I recently started using tkinter and the canvas widget, and I think I really messed something up! I'm running a pdsoft version Python 2.6.2 (r262:71600, Sep 24 2009, 11:47:14) on UNIX (AFS system - not by choice)! Some background info, might be useful: A few weeks ago I could happily run my .py script, though knew I may have been doing something wrong (not opening/closing a loop as needed): Every time I would run my script, the 'canvas' with my images would pop up, and then when I'd edit my file and re-run the script, I'd simply close the 'old' canvas with the mouse when the new canvas would appear. I could not figure out how to elegantly exit using tkinter/canvas (tried Google searches but didn't find anything after a while). Here is an excerpt from the script that worked (comments deleted): === from Tkinter import * window=Tk() window.title('Canvas Window') evol=Canvas(window,width=500,height=1000,background='white') evol.pack() evol.create_oval(90,210,170,290,fill=light blue) evol.create_oval(350,230,390,270,fill=cyan) evol.create_text(130,250,text='He',font=('verdana',11)) evol.create_line(170,250,350,250,width=3) evol.create_polygon(350,250,340,240,340,260,fill=black) evol.create_text(255,230,text=' MT ',font=('verdana',11)) evol.create_text(50,240,text='t=102',font=('verdana',11)) evol.create_text(50,260,text='M1=0.96',font=('verdana',11)) evol.create_text(440,260,text='M2=6.62',font=('verdana',11)) evol.create_text(440,240,text='a=258',font=('verdana',11)) retval = evol.postscript(file=blah.eps, height=1000, width=500, colormode=color) === Anyway this all seemed to be working, until last week when I ran my script again, and now I receive the following message: === TclError Traceback (most recent call last) /MYDIR/ipython console in module() /MYDIR/evolgrid.py in module() 26 27 ## create a window: --- 28 window=Tk() 29 ## change window's name to 'Canvas Window': 30 window.title('Canvas Window') /usr/common/pdsoft/appl/pyapps/lib/python2.6/lib-tk/Tkinter.pyc in __init__(self, screenName, baseName, className, useTk, sync, use) 1641 baseName = baseName + ext 1642 interactive = 0 - 1643 self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) 1644 if useTk: 1645 self._loadtk() TclError: out of stack space (infinite loop?) === Also, since this problem, now whenever I start up with 'ipython -pylab', and type figure() (just as a test), I get the following message: === TclError Traceback (most recent call last) /MYDIR/ipython console in module() /usr/common/pdsoft/appl/pyapps/lib/python2.6/site-packages/matplotlib/pyplot.pyc in figure(num, figsize, dpi, facecolor, edgecolor, frameon, FigureClass, **kwargs) 268 frameon=frameon, 269 FigureClass=FigureClass, -- 270 **kwargs) 271 272 # make this figure current on button press event /usr/common/pdsoft/appl/pyapps/lib/python2.6/site-packages/matplotlib/backends/backend_tkagg.pyc in new_figure_manager(num, *args, **kwargs) 81 FigureClass = kwargs.pop('FigureClass', Figure) 82 figure = FigureClass(*args, **kwargs) --- 83 window = Tk.Tk() 84 canvas = FigureCanvasTkAgg(figure, master=window) 85 figManager = FigureManagerTkAgg(canvas, num, window) /usr/common/pdsoft/appl/pyapps/lib/python2.6/lib-tk/Tkinter.pyc in __init__(self, screenName, baseName, className, useTk, sync, use) 1641 baseName = baseName + ext 1642 interactive = 0 - 1643 self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) 1644 if useTk: 1645 self._loadtk() TclError: out of stack space (infinite loop?) === So, something is really messed up! Can someone help me? :-/ -- View this message in context: http://old.nabble.com/pylab-TclError%3A-out-of-stack-space---tkinter--tp33465359p33465359.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Changing a single marker on a line
Hi, I have a very simple request - I am drawing a line with n points, using a particle marker - something like: x = np.linspace(1,10,11) ** 2 y = np.linspace(1,10,11) plot(x,y,'ro') Is there any way to change the 7th dot (7, 49) to be a blue star instead of a red circle? I was considering using the scatter function to scatter points 1:6 and 8:10 separately with 'ro' and then scatter 7 with the right properties... is that the easiest way? Thanks a lot, Federico -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Has nxutils been removed from mpl?
+ one on this issue. One of the big advantages of the nxutils points in poly is that you could pass it a large numpy array of points and get back a mask. We found this to be significantly faster than using looping through the single point in poly algorithms from packages like shapely. Echoing Jorge's question how would we do this using contains_point(). - dharhas Jorge Scandaliaris jorgesmbox...@yahoo.es 3/8/2012 3:33 AM Benjamin Root ben.root@... writes: snip Essentially, you make a Path object using the vertices, and then use its contains_point() method. Ben Root OK, but given that contains_point works with a *single* point at a time, I have to call it for all my points which is a bit more cumbersome, or am I missing something? Jorge -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Changing a single marker on a line
On Thu, Mar 8, 2012 at 10:18 AM, federico vaggi vaggi.feder...@gmail.comwrote: Hi, I have a very simple request - I am drawing a line with n points, using a particle marker - something like: x = np.linspace(1,10,11) ** 2 y = np.linspace(1,10,11) plot(x,y,'ro') Is there any way to change the 7th dot (7, 49) to be a blue star instead of a red circle? I was considering using the scatter function to scatter points 1:6 and 8:10 separately with 'ro' and then scatter 7 with the right properties... is that the easiest way? Thanks a lot, Federico Pretty much. Although, you could possibly just do the first plot normally and then have the scatter function simply plot the red star over the blue circle (maybe make the star size bigger to fully cover the blue circle?). Ben Root -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Changing a single marker on a line
federico vaggi: I am drawing a line with n points, using a particle marker - something like: x = np.linspace(1,10,11) ** 2 y = np.linspace(1,10,11) ZZZ=plot(x,y,'ro') Is there any way to change the 7th dot (7, 49) to be a blue star instead of a red circle? I was considering using the scatter function to scatter points 1:6 and 8:10 separately with 'ro' and then scatter 7 with the right properties... is that the easiest way? I might be silly, but I believe that this IS the easiest way. In the program above ZZZ (which I put myself) is a list containing just ONE Line2D object, with a common set of properties, such as set_markerfacecolor() or set_marker_size(), and if you use them, all markers change. The data attached to the plot have no information about markers. So, if a way exists at all, to change just one marker, it would be quite involved, and a second plot seems easier than anything else. But a true specialist might know The Real Magic... Jerzy Karczmarczuk -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Has nxutils been removed from mpl?
On Thu, Mar 8, 2012 at 10:32 AM, Benjamin Root ben.r...@ou.edu wrote: +1 as well. I just took another look at the Path object and I see no such function. The lack of this function is a problem for me as well in my existing apps. In order to deprecate nxutils, this functionality needs to be added to Path. Otherwise, nxutils *must* be reinstated before the next release. Michael has already agreed to make a nxutils compatibility layer that would have the same interface as the old nxutils. So we are talking about performance, not core functionality. We should remember that Michael did the lion's share of the work on porting mpl to python 3 ( https://github.com/matplotlib/matplotlib/pull/565/commits). He elected not to port all of the C++ if he could replace some of the functionality with the core. So those who rely on bare metal speed the you are getting in nxutils should step up to either : 1) help with the port of nxutils to python 3 2) help with exposing methods in _path.cpp that are almost as fast or faster 3) live with slower speeds in the compatibility layer he has agreed to write 4) ask (nicely) for someone to help you I prefer option 2 because this is fairly easy and avoids code redundancy. It would take just a few lines of extra code to do this with the python sequence protocol as inputs and python lists as return values. It would take a bit more to support numpy arrays as input and output, and we should get input from Michael about the desirability of making _path.cpp depend on numpy. I don't see the harm, but I'd like to verify. In my opinion, a slower implementation in a nxutils.py compatibility module is not a release stopper, even if it is undesirable. JDH -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Has nxutils been removed from mpl?
On Thu, Mar 8, 2012 at 10:47 AM, John Hunter jdh2...@gmail.com wrote: I prefer option 2 because this is fairly easy and avoids code redundancy. It would take just a few lines of extra code to do this with the python sequence protocol as inputs and python lists as return values. It would take a bit more to support numpy arrays as input and output, and we should get input from Michael about the desirability of making _path.cpp depend on numpy. I don't see the harm, but I'd like to verify. In my opinion, a slower implementation in a nxutils.py compatibility module is not a release stopper, even if it is undesirable. +1 Python 3 support is more important and, quite frankly, overdue--especially given how long it's been sitting in the tree. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Has nxutils been removed from mpl?
On Thu, Mar 8, 2012 at 10:47 AM, John Hunter jdh2...@gmail.com wrote: On Thu, Mar 8, 2012 at 10:32 AM, Benjamin Root ben.r...@ou.edu wrote: +1 as well. I just took another look at the Path object and I see no such function. The lack of this function is a problem for me as well in my existing apps. In order to deprecate nxutils, this functionality needs to be added to Path. Otherwise, nxutils *must* be reinstated before the next release. Michael has already agreed to make a nxutils compatibility layer that would have the same interface as the old nxutils. So we are talking about performance, not core functionality. We should remember that Michael did the lion's share of the work on porting mpl to python 3 ( https://github.com/matplotlib/matplotlib/pull/565/commits). He elected not to port all of the C++ if he could replace some of the functionality with the core. So those who rely on bare metal speed the you are getting in nxutils should step up to either : 1) help with the port of nxutils to python 3 2) help with exposing methods in _path.cpp that are almost as fast or faster 3) live with slower speeds in the compatibility layer he has agreed to write 4) ask (nicely) for someone to help you I prefer option 2 because this is fairly easy and avoids code redundancy. It would take just a few lines of extra code to do this with the python sequence protocol as inputs and python lists as return values. It would take a bit more to support numpy arrays as input and output, and we should get input from Michael about the desirability of making _path.cpp depend on numpy. I don't see the harm, but I'd like to verify. In my opinion, a slower implementation in a nxutils.py compatibility module is not a release stopper, even if it is undesirable. JDH Don't get me wrong. If help is needed, I can certainly provide it since it is my itch. I am just a little exasperated with how this issue has been handled up to now. The shim is a very good idea and it should have been done back when the py3k merge happened. I didn't press the issue then because I was traveling and didn't have time to examine the issue closely, and having _nxutils.so still in my build hide the problem from me (my own fault). As for shim implementation, I would be willing to accept a slightly slower function now (with the promise of improvements later), but if the implementation is too much slower, then effort will need to be made to get it up to acceptable levels. I know of several users **cough**my future employer**cough** who uses functionality such as this, and they would not be happy if their products are dragged down by such a bottleneck. Probably about time I dug more into CXX wrapped stuff... Ben Root -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Has nxutils been removed from mpl?
_path.cpp already has a number of methods that use Numpy arrays (John is mistaken that it doesn't depend on Numpy), so adding another is no problem. It was my understanding that nxutils was an internal usage module and not part of the public API, and therefore could be removed as long as all of the internal references were updated. It doesn't have a '_' prefix, so of course it being private wasn't explicit, but there are number of things in matplotlib that fall into that category. Apparently, I was mistaken and there are a lot of users using it from outside. It shouldn't be a problem to build a compatibility shim -- I'd much rather do that than have multiple functions -- and adding a points_in_poly to _path.cpp should be pretty straightforward. Mike On 03/08/2012 12:16 PM, Benjamin Root wrote: On Thu, Mar 8, 2012 at 10:47 AM, John Hunter jdh2...@gmail.com mailto:jdh2...@gmail.com wrote: On Thu, Mar 8, 2012 at 10:32 AM, Benjamin Root ben.r...@ou.edu mailto:ben.r...@ou.edu wrote: +1 as well. I just took another look at the Path object and I see no such function. The lack of this function is a problem for me as well in my existing apps. In order to deprecate nxutils, this functionality needs to be added to Path. Otherwise, nxutils *must* be reinstated before the next release. Michael has already agreed to make a nxutils compatibility layer that would have the same interface as the old nxutils. So we are talking about performance, not core functionality. We should remember that Michael did the lion's share of the work on porting mpl to python 3 (https://github.com/matplotlib/matplotlib/pull/565/commits). He elected not to port all of the C++ if he could replace some of the functionality with the core. So those who rely on bare metal speed the you are getting in nxutils should step up to either : 1) help with the port of nxutils to python 3 2) help with exposing methods in _path.cpp that are almost as fast or faster 3) live with slower speeds in the compatibility layer he has agreed to write 4) ask (nicely) for someone to help you I prefer option 2 because this is fairly easy and avoids code redundancy. It would take just a few lines of extra code to do this with the python sequence protocol as inputs and python lists as return values. It would take a bit more to support numpy arrays as input and output, and we should get input from Michael about the desirability of making _path.cpp depend on numpy. I don't see the harm, but I'd like to verify. In my opinion, a slower implementation in a nxutils.py compatibility module is not a release stopper, even if it is undesirable. JDH Don't get me wrong. If help is needed, I can certainly provide it since it is my itch. I am just a little exasperated with how this issue has been handled up to now. The shim is a very good idea and it should have been done back when the py3k merge happened. I didn't press the issue then because I was traveling and didn't have time to examine the issue closely, and having _nxutils.so still in my build hide the problem from me (my own fault). As for shim implementation, I would be willing to accept a slightly slower function now (with the promise of improvements later), but if the implementation is too much slower, then effort will need to be made to get it up to acceptable levels. I know of several users **cough**my future employer**cough** who uses functionality such as this, and they would not be happy if their products are dragged down by such a bottleneck. Probably about time I dug more into CXX wrapped stuff... Ben Root -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Has nxutils been removed from mpl?
On 03/08/2012 07:16 AM, Benjamin Root wrote: On Thu, Mar 8, 2012 at 10:47 AM, John Hunter jdh2...@gmail.com mailto:jdh2...@gmail.com wrote: On Thu, Mar 8, 2012 at 10:32 AM, Benjamin Root ben.r...@ou.edu mailto:ben.r...@ou.edu wrote: +1 as well. I just took another look at the Path object and I see no such function. The lack of this function is a problem for me as well in my existing apps. In order to deprecate nxutils, this functionality needs to be added to Path. Otherwise, nxutils *must* be reinstated before the next release. Michael has already agreed to make a nxutils compatibility layer that would have the same interface as the old nxutils. So we are talking about performance, not core functionality. We should remember that Michael did the lion's share of the work on porting mpl to python 3 (https://github.com/matplotlib/matplotlib/pull/565/commits). He elected not to port all of the C++ if he could replace some of the functionality with the core. So those who rely on bare metal speed the you are getting in nxutils should step up to either : 1) help with the port of nxutils to python 3 2) help with exposing methods in _path.cpp that are almost as fast or faster 3) live with slower speeds in the compatibility layer he has agreed to write 4) ask (nicely) for someone to help you I prefer option 2 because this is fairly easy and avoids code redundancy. It would take just a few lines of extra code to do this with the python sequence protocol as inputs and python lists as return values. It would take a bit more to support numpy arrays as input and output, and we should get input from Michael about the desirability of making _path.cpp depend on numpy. I don't see the harm, but I'd like to verify. In my opinion, a slower implementation in a nxutils.py compatibility module is not a release stopper, even if it is undesirable. JDH Don't get me wrong. If help is needed, I can certainly provide it since it is my itch. I am just a little exasperated with how this issue has been handled up to now. The shim is a very good idea and it should have been done back when the py3k merge happened. I didn't press the issue then because I was traveling and didn't have time to examine the issue closely, and having _nxutils.so still in my build hide the problem from me (my own fault). As for shim implementation, I would be willing to accept a slightly slower function now (with the promise of improvements later), but if the implementation is too much slower, then effort will need to be made to get it up to acceptable levels. I know of several users **cough**my future employer**cough** who uses functionality such as this, and they would not be happy if their products are dragged down by such a bottleneck. For my own purposes I decided to simply copy the pnpoly core and write a cython wrapper, since nxutils did not seem to have a secure future in mpl. If anyone is interested in this approach, see the files _pnpoly.c and utility.pyx (last function therein) in the num/src subdirectory of my pycurrents repo: http://currents.soest.hawaii.edu/hgstage/pycurrents/shortlog/tip. The wrapper is brand-new and very lightly tested; I suspect it could be improved considerably. (Also, at present it has only the points_in_poly function.) Probably about time I dug more into CXX wrapped stuff... mpl strategy question: stick with CXX and hand-wrapping exclusively, or start using cython? Eric Ben Root -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Has nxutils been removed from mpl?
On 03/08/2012 12:35 PM, Michael Droettboom wrote: It shouldn't be a problem to build a compatibility shim -- I'd much rather do that than have multiple functions Oops -- hit send too soon. I meant to say I'd much rather do that than have multiple functions that do virtually the same thing Mike Mike On 03/08/2012 12:16 PM, Benjamin Root wrote: On Thu, Mar 8, 2012 at 10:47 AM, John Hunter jdh2...@gmail.com mailto:jdh2...@gmail.com wrote: On Thu, Mar 8, 2012 at 10:32 AM, Benjamin Root ben.r...@ou.edu mailto:ben.r...@ou.edu wrote: +1 as well. I just took another look at the Path object and I see no such function. The lack of this function is a problem for me as well in my existing apps. In order to deprecate nxutils, this functionality needs to be added to Path. Otherwise, nxutils *must* be reinstated before the next release. Michael has already agreed to make a nxutils compatibility layer that would have the same interface as the old nxutils. So we are talking about performance, not core functionality. We should remember that Michael did the lion's share of the work on porting mpl to python 3 (https://github.com/matplotlib/matplotlib/pull/565/commits). He elected not to port all of the C++ if he could replace some of the functionality with the core. So those who rely on bare metal speed the you are getting in nxutils should step up to either : 1) help with the port of nxutils to python 3 2) help with exposing methods in _path.cpp that are almost as fast or faster 3) live with slower speeds in the compatibility layer he has agreed to write 4) ask (nicely) for someone to help you I prefer option 2 because this is fairly easy and avoids code redundancy. It would take just a few lines of extra code to do this with the python sequence protocol as inputs and python lists as return values. It would take a bit more to support numpy arrays as input and output, and we should get input from Michael about the desirability of making _path.cpp depend on numpy. I don't see the harm, but I'd like to verify. In my opinion, a slower implementation in a nxutils.py compatibility module is not a release stopper, even if it is undesirable. JDH Don't get me wrong. If help is needed, I can certainly provide it since it is my itch. I am just a little exasperated with how this issue has been handled up to now. The shim is a very good idea and it should have been done back when the py3k merge happened. I didn't press the issue then because I was traveling and didn't have time to examine the issue closely, and having _nxutils.so still in my build hide the problem from me (my own fault). As for shim implementation, I would be willing to accept a slightly slower function now (with the promise of improvements later), but if the implementation is too much slower, then effort will need to be made to get it up to acceptable levels. I know of several users **cough**my future employer**cough** who uses functionality such as this, and they would not be happy if their products are dragged down by such a bottleneck. Probably about time I dug more into CXX wrapped stuff... Ben Root -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Error when saving as PDF using $\alpha$ and 'text.usetex':True
Alejandro Weinstein alejandro.weinst...@gmail.com writes: TypeError: unicode argument expected, got 'str' I am using MPL verion 1.2.x (built from commit 396a6446). That reminds me of a problem fixed in commit 680edf7, so could you either try cherry-picking that commit or updating to a later revision? Your test case doesn't produce an error on a recent-ish master. -- Jouni K. Seppänen http://www.iki.fi/jks -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] histogram and a line
Jerzy et al, Check out the axvline method (of pyplot or an axes object). You'll only have to specify the x-value, and it'll won't rescale your y-axis. -paul On Thu, Mar 8, 2012 at 4:50 AM, Jerzy Karczmarczuk jerzy.karczmarc...@unicaen.fr wrote: Nicolas Rougier, (to Mic, who can't see a histogram and a line simultaneously): You need to specify the ylim because your height may be larger than your histogram and then you cannot see it. I suspect something similar. The height of matplot_hist.png is 0.040. The line goes from 0 to 300. The histogram reduces to the bottom line. There is no immediate relation between max(hist_data) and the height of a *normed* histogram. And, please, if you want to point out the difficulties in making your programs fulfil your aims, show the REAL, COMPLETE programs, perhaps with fake, random data, but without useless : hist_data=[] And don't call a mean: median or vice-versa... Scaling the axes is easy. ylim should be changed, use also the extent parameter (see doc). Drawing axes shifted, as in hist.png is a bit more involved, and I don't know if you really want that as well. Jerzy K. -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Has nxutils been removed from mpl?
There is a proposed solution to all of this here: https://github.com/matplotlib/matplotlib/pull/746 Please test -- I don't have any nxutils-using code myself, and matplotlib itself has none. We should probably convert some of the nxutils code in the wild into some unit tests. Mike On 03/08/2012 12:37 PM, Benjamin Root wrote: On Thu, Mar 8, 2012 at 11:16 AM, Benjamin Root ben.r...@ou.edu mailto:ben.r...@ou.edu wrote: On Thu, Mar 8, 2012 at 10:47 AM, John Hunter jdh2...@gmail.com mailto:jdh2...@gmail.com wrote: On Thu, Mar 8, 2012 at 10:32 AM, Benjamin Root ben.r...@ou.edu mailto:ben.r...@ou.edu wrote: +1 as well. I just took another look at the Path object and I see no such function. The lack of this function is a problem for me as well in my existing apps. In order to deprecate nxutils, this functionality needs to be added to Path. Otherwise, nxutils *must* be reinstated before the next release. Michael has already agreed to make a nxutils compatibility layer that would have the same interface as the old nxutils. So we are talking about performance, not core functionality. We should remember that Michael did the lion's share of the work on porting mpl to python 3 (https://github.com/matplotlib/matplotlib/pull/565/commits). He elected not to port all of the C++ if he could replace some of the functionality with the core. So those who rely on bare metal speed the you are getting in nxutils should step up to either : 1) help with the port of nxutils to python 3 2) help with exposing methods in _path.cpp that are almost as fast or faster 3) live with slower speeds in the compatibility layer he has agreed to write 4) ask (nicely) for someone to help you I prefer option 2 because this is fairly easy and avoids code redundancy. It would take just a few lines of extra code to do this with the python sequence protocol as inputs and python lists as return values. It would take a bit more to support numpy arrays as input and output, and we should get input from Michael about the desirability of making _path.cpp depend on numpy. I don't see the harm, but I'd like to verify. In my opinion, a slower implementation in a nxutils.py compatibility module is not a release stopper, even if it is undesirable. JDH Don't get me wrong. If help is needed, I can certainly provide it since it is my itch. I am just a little exasperated with how this issue has been handled up to now. The shim is a very good idea and it should have been done back when the py3k merge happened. I didn't press the issue then because I was traveling and didn't have time to examine the issue closely, and having _nxutils.so still in my build hide the problem from me (my own fault). As for shim implementation, I would be willing to accept a slightly slower function now (with the promise of improvements later), but if the implementation is too much slower, then effort will need to be made to get it up to acceptable levels. I know of several users **cough**my future employer**cough** who uses functionality such as this, and they would not be happy if their products are dragged down by such a bottleneck. Probably about time I dug more into CXX wrapped stuff... Ben Root Looking over the code, it looks like we could generalize point_in_path_impl() into points_in_path_impl(). The current code iterates through the path vertices to test a single point. Putting this action inside a loop (for each point that we want to test) would mean that this iterator has to be processed each time, which I suspect would kill performance when the number of vertices is far greater than the number of test points. Tinkering Ben Root -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list
[Matplotlib-users] imshow of scalar 2D array using a shared color scale
Hi, I've got a datasets of a pixel particle detector for a number of independent events. I'd like to show them in a row but have them all use the same value and thus color range. What's the most straigtforward way to do this? Cheers, Wolfgang Draxinger -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Errorbars not drawn correctly in logarithmic scales
Hi, I've a problem with some errorbars not drawn correctly in (double) logarithmic plots. See this PDF for an example: http://dl.wolfgang-draxinger.net/C6_77MeV_raddamage.pdf The vertical errorbar for the datapoint at x=1e3 are not drawn. Similar also happens for some horizontal errorbars. Using the very same drawing commands, except switching to a logarithmic scaling the errorbars draw just fine. So what's going on there? Wolfgang Draxinger -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Errorbars not drawn correctly in logarithmic scales
On Thursday, March 8, 2012, Wolfgang Draxinger wdraxinger.maill...@draxit.de wrote: Hi, I've a problem with some errorbars not drawn correctly in (double) logarithmic plots. See this PDF for an example: http://dl.wolfgang-draxinger.net/C6_77MeV_raddamage.pdf The vertical errorbar for the datapoint at x=1e3 are not drawn. Similar also happens for some horizontal errorbars. Using the very same drawing commands, except switching to a logarithmic scaling the errorbars draw just fine. So what's going on there? Wolfgang Draxinger Which version of matplotlib are you using? Also, are you setting the log scale before (preferred) or after (won't work) the call to hist()? Ben Root -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Errorbars not drawn correctly in logarithmic scales
On Thursday, March 8, 2012, Benjamin Root ben.r...@ou.edu wrote: On Thursday, March 8, 2012, Wolfgang Draxinger wdraxinger.maill...@draxit.de wrote: Hi, I've a problem with some errorbars not drawn correctly in (double) logarithmic plots. See this PDF for an example: http://dl.wolfgang-draxinger.net/C6_77MeV_raddamage.pdf The vertical errorbar for the datapoint at x=1e3 are not drawn. Similar also happens for some horizontal errorbars. Using the very same drawing commands, except switching to a logarithmic scaling the errorbars draw just fine. So what's going on there? Wolfgang Draxinger Which version of matplotlib are you using? Also, are you setting the log scale before (preferred) or after (won't work) the call to hist()? Ben Root Grrr, not hist(), but errorbar(). Ben Root -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] imshow of scalar 2D array using a shared color scale
On Thursday, March 8, 2012, Wolfgang Draxinger wdraxinger.maill...@draxit.de wrote: Hi, I've got a datasets of a pixel particle detector for a number of independent events. I'd like to show them in a row but have them all use the same value and thus color range. What's the most straigtforward way to do this? Cheers, Wolfgang Draxinger Quick and dirty way is to set vmin and vmax for each of them using common values. You could also pass in a norm argument that does something similar. Ben Root -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] open ascii grid data and plot
In my GIS experience, rasters don't have prj files. That's something that seems to be pretty specific to ESRI shapefiles. Point is, I don't think that's going to help you. All of the basemap examples use netcdf files. I think your path of least resistance right now is to figure out how to convert your text file to a numpy array (check?), and then that array to a netcdf that is structured such that you can follow the basemap examples: http://matplotlib.github.com/basemap/users/examples.html Hope that helps, -paul On Wed, Mar 7, 2012 at 8:21 PM, questions anon questions.a...@gmail.com wrote: Hi all, I am still having a problem with the same code. I am not sure if maybe the problem is how I read the data in as numpy.genfromtxt Is there a step I need to take to convert the data to numpy array to then read into matplotlib? Thanks On Fri, Mar 2, 2012 at 11:49 AM, questions anon questions.a...@gmail.com wrote: python, numpy through enthought - Python 2.7.2 |EPD 7.1-1 (32-bit)| (default, Jul 3 2011, 15:13:59) [MSC v.1500 32 bit (Intel)] on win32 imports at the top of the script: import numpy as N import matplotlib.pyplot as plt from numpy import ma as MA from mpl_toolkits.basemap import Basemap import os On Thu, Mar 1, 2012 at 4:42 PM, Benjamin Root ben.r...@ou.edu wrote: On Wednesday, February 29, 2012, questions anon wrote: I have had some progress reading in the data but am unsure how to create lats and lons from the info I have (see above). the error I am receiving is: Traceback (most recent call last): File d:\plotrainfall.py, line 40, in module CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet) File C:\Python27\lib\site-packages\mpl_toolkits\basemap\__init__.py, line 3072, in contourf np.logical_or(outsidemask,np.logical_or(ma.getmaskarray(data),xymask)) AttributeError: logical_or from the below code: onefile=rE:/test_in/r19000117.txt f=N.genfromtxt(onefile, skip_header=6, dtype=float, names=True) print f map = Basemap(projection='merc',llcrnrlat=-45,urcrnrlat=-9, llcrnrlon=111.975,urcrnrlon=156.525,lat_ts=0,resolution='i') map.drawcoastlines() map.drawstates() xi=N.linspace(111.975, 156.275, 886) yi=N.linspace(-44.525, -9.975, 691) x,y=map(*N.meshgrid(xi,yi)) plt.title('rainfall') CS = map.contourf(x,y, f, 15,cmap=plt.cm.jet) l,b,w,h =0.1,0.1,0.8,0.8 cax = plt.axes([l+w+0.025, b, 0.025, h]) plt.colorbar(CS,cax=cax, drawedges=True) plt.savefig((os.path.join(OutputFolder, 'rainfall.png'))) plt.show() plt.close() How did you install numpy? Which version are you using? What are your imports at the top of this script? Ben Root -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Centering Text with axes_divider
Greetings, Let me begin by saying that I've fallen in love with ImageGrid. I love the control it gives me in setting up plots, and I really like the control it offers for setting up a colorbar. Unfortunately, like all relationships, ImageGrid and I have hit a rough patch. I like to manually place titles and other boxes of texts on plots that I make using ImageGrid. However, to center things I have to know what the axes bounds are so I can do the centering calculations. Unfortunately, when using ImageGrid, or axes_divider, I have yet to find a way to get the axes bounds that are actually used to do the plotting. When I try to use ax.get_position().bounds I get the pre-adjusted bounds, even if I use plt.draw() before requesting the axes_positions. This means the only way I can center the text is by guessing what the final axes bounds will be. Is there any way of getting the final bounds? It appears anchored text is able to do it, but I haven't been able to... Here's a self-contained example script that demonstrates the problem. I don't use ImageGrid, instead using axes_divider, however this is the same problem that AxesGrid has. (I'm guessing this is because ImageGrid ultimately does what I did here behind the scenes.) https://gist.github.com/2004869 Thanks for any help! Patrick --- Patrick Marsh Ph.D. Student / Liaison to the HWT School of Meteorology / University of Oklahoma Cooperative Institute for Mesoscale Meteorological Studies National Severe Storms Laboratory http://www.patricktmarsh.com -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] open ascii grid data and plot
On Wednesday, March 7, 2012, questions anon questions.a...@gmail.com wrote: Hi all, I am still having a problem with the same code. I am not sure if maybe the problem is how I read the data in as numpy.genfromtxt Is there a step I need to take to convert the data to numpy array to then read into matplotlib? Sorry for the delay. As far as I can tell, you are doing everything correctly. The error you are getting would seem to indicate something wrong with your EPD install, or perhaps a conflict with another install on numpy or mpl. I would suggest completely clearing out your python and EPD install and reinstalling it fresh. Ben Root -- Virtualization Cloud Management Using Capacity Planning Cloud computing makes use of virtualization - but cloud computing also focuses on allowing computing to be delivered as a service. http://www.accelacomm.com/jaw/sfnl/114/51521223/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users