Re: [Matplotlib-users] wx backend scaling problem
Hi Michael, Michael Droettboom wrote: Well, that was a good puzzle! Glad I got your neurons firing. This seems like a safe fix to me, but anyone who currently extends the Wx Frame (meaning the whole window etc.) and is unknowingly compensating for this effect may have problems after my change. Many thanks for looking at this. I applied your fix and it works for me. Gary R. - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Unable to Plot Date Axis Due To TypeError: a float is required
I'm getting a nonsensical error when attempting to make a simple plot with a date axis. Googling shows this similar errors, but none with a date axis. What could be causing this? import datetime from pylab import figure, show fig = figure() ax = fig.add_subplot(111) dates = [datetime.date(2008, 1, 30),datetime.date(2008, 1, 31)] values = [10.25, 10.0] ax.plot_date(dates, values)#, '-') Traceback (most recent call last): File stdin, line 1, in module File /usr/lib/python2.5/site-packages/matplotlib/axes.py, line 2585, in plot_date ret = self.plot(x, y, fmt, **kwargs) File /usr/lib/python2.5/site-packages/matplotlib/axes.py, line 2535, in plot for line in self._get_lines(*args, **kwargs): File /usr/lib/python2.5/site-packages/matplotlib/axes.py, line 428, in _grab_next_args for seg in self._plot_3_args(remaining, **kwargs): File /usr/lib/python2.5/site-packages/matplotlib/axes.py, line 404, in _plot_3_args func(x[:,j], y[:,j]) File /usr/lib/python2.5/site-packages/matplotlib/axes.py, line 385, in makeline axes=self.axes, File /usr/lib/python2.5/site-packages/matplotlib/lines.py, line 226, in __init__ self.set_data(xdata, ydata) File /usr/lib/python2.5/site-packages/matplotlib/lines.py, line 315, in set_data self.recache() File /usr/lib/python2.5/site-packages/matplotlib/lines.py, line 320, in recache x = ma.asarray(self.convert_xunits(self._xorig), Float) File /usr/lib/python2.5/site-packages/numpy/core/ma.py, line 2122, in asarray return array(data, dtype=dtype, copy=0) File /usr/lib/python2.5/site-packages/numpy/core/ma.py, line 573, in __init__ self._data = c.astype(tc) TypeError: a float is required - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Major Issue with 0.91.2 and Python-2.5
I suspect there is an .afm font file on your new system that is untested with matplotlib and exhibiting something new. I would first try to track down which font file it is, and then send it to me off list and I'll have a look at what might be tripping up matplotlib. Cheers, Mike Rich Shepard wrote: I upgraded my notebook to Slackware-12.0 (which includes python-2.5) and discovered that the application I'm developing no longer ran. Turns out that matplotlib went missing during the upgrade. So, I just built matplotlib-0.91.2 using the same matplotlib.Slackbuild script I used on my workstation/server, but this time it failed. The font manager seems to be the issue; the error message repeatedly is: Found an unknown keyword in AFM header (was Underline). Specifically, the error is in File /usr/lib/Python2.5/site-packages/matplotlib/afm.py, line 166, in _parse_char_metrics name=vals[2].split()[1] IndexError: List index out of range Is this unique to me? What do I do to fix the problem? TIA, Rich -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [newbie] live plots of multiple lines
Matthias Michler wrote: plot([x1], [y1], bo, [x2], [y2], r+) This didn't work :-S - the first time I call show(), execution never comes back to my script so the code never gets to plot any further points - if I put the show after the plotting loop (which means I don't get the live plotting I'm after) then there are no lines between the points (well, the points don't show at all, but I'm guessing it's because there's no lines between the points) - looking at the example, I'm left wondering how to pass keyword parameters such as label or use other methods such as plot_date Any help greatfully received! Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [newbie] live plots of multiple lines
On Tue, 11 Mar 2008, Chris Withers apparently wrote: the first time I call show() http://matplotlib.sourceforge.net/faq.html#SHOW hth, Alan Isaac - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [newbie] live plots of multiple lines
Alan G Isaac wrote: On Tue, 11 Mar 2008, Chris Withers apparently wrote: the first time I call show() http://matplotlib.sourceforge.net/faq.html#SHOW Okay, that tells me that I prettymuch don't want to be using show(), but I don't think I want interactive mode either... What I'm trying to do is run a script and plot-and-show as I go. The script reads the data to be plotted, but each set of points takes up to 20 minutes to generate, so I want to see the points appear on the graph as they arrive. Is this possible? If so, how? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] colorbar problem
Le Sunday 09 March 2008 14:32:05 Eric Firing, vous avez écrit : [EMAIL PROTECTED] wrote: Hello, I have some stupid questions about how to use colorbar. 1) I would like to be able to put the colorbar where I went: top, bottom, left, right. For what I see I can do only a vertical left and horizontal bottom ones (with a simple use of the function). I know that it's possible to do a colorbar only but it's difficult to place them a little bit automatically and that bring my second question. This looks like a feature request: instead of specifying horizontal or vertical, be able to specify top, bottom, left, or right. This is fairly easy in principle, but there are some wrinkles such that I am not sure it would be satisfactory in practice--some custom adjustments might usually be needed depending on whether the main axes have a title (in the case of top) or an xlabel (in the case of left). You may be better off simply figuring out what main and colorbar axes positions work best for your particular case and then making those axes explicitly. I agree it's more feature request. I'll look on how to implement your suggestion. 2) I would like that the colorbar with exactly the same size than the image I plot with pcolor. It's working when I'm not using the aspect='equal' in the subplot but not with this option. Naturally I want to not change the aspect of my image and so it's a big problem for me. The only solution I found is to manipulate the colorbar with the shrink valu but it's a little bit painfull especially the value change for each pcolor image (they doesn't have always the same size). This is a common request, and a reasonable one, but unfortunately it is not straightforward to implement automatically given mpl's internal structure. Again, however, you get the desired result quite easily by creating your own axes explicitly. This is what I was afraid... So I have a stupid question but how to do this, create the axes at the same place than the pcolor image? I can see how I can recuperate the axes coordinates but I don't know how to use them: im = pylab.pcolor(a) ax = im.get_axes() cs = pylab.colorbar() but after I'm a little bit lost... 3) I would like to give a label to the colorbar (ie if the colorbar is at the bottom a label under the colorbar etc). To tell people what means the colors but I didn't find anyway to do it. xlabel work for the pcolor object (as expected) and there are no colorbar.xlabel function. Use the set_label() method. ... cbar = fig1.colorbar(im,orientation='horizontal') cbar.set_label('label') ... Great thanks it's working perfectly. Eric Thank you for your help, N. - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [newbie] live plots of multiple lines
Ryan May wrote: Right, the show() command starts the GUI's mainloop, which blocks execution of the script until you close the figure. What you probably want is something like the dynamic_demo.py example. ...which barfes for me: Traceback (most recent call last): File dynamic_demo.py, line 3, in module import gobject ImportError: No module named gobject What does that mean? Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] contour question
Hello, I'm using a svn version of matplotlib and the API changed for contour. I want to have the coordinate of the contour. Before Eric Firing (I think) gave a solution to do it: val = contour(xRange,yRange,delchi2,[1]) t = asarray(val.collections[0].get_verts()) but now get_verts doesn't exist anymore. I tried to do: cs = contour(a) path = cs.collections[0].get_paths() but I don't know how to use it. Basically I think that I have the contour coordinate but I don't know how to recuperate them. I need it to export them in a data file so it's the reason I want to recuperate them. Thank you for any help N. ps: It's a little bit difficult to access to the help for a method now some, perhaps most, of them are missing a docstring. So it's difficult to understand what it is the meaning of each of them. example: col.get_paths? Type: instancemethod Base Class: type 'instancemethod' String Form:bound method LineCollection.get_paths of matplotlib.collections.LineCollection object at 0x9038a4c Namespace: Interactive File: /usr/lib/python2.5/site-packages/matplotlib/collections.py Definition: col.get_paths(self) Docstring: no docstring - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Basemap, Mercator Projection and pcolor
Hi, I've successfully plotted gridded data on a basemap cyl projection using pcolor: mp = Basemap(projection=cyl, resolution=l, llcrnrlon=0.0, urcrnrlon=30.0, llcrnrlat=-5.0, urcrnrlat=5.0) pc = mp.pcolor(X, Y, zvalsm, cmap=cm.jet) However, if I simply I change the projection type to merc, adding appropriate lat_ts, I get the projection but the pcolor fails to plot on it: mp = Basemap(projection=merc, lat_ts=0.0, resolution=l, llcrnrlon=0.0, urcrnrlon=30.0, llcrnrlat=-5.0, urcrnrlat=5.0)' pc = mp.pcolor(X, Y, zvalsm, cmap=cm.jet) Any ideas? I am using matplotlib 0.91.2 and basemap 0.9.9 on CentOS 4.0 with Python 2.3. Thanks, Rich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] contour question
.get_paths() returns a list of Path objects. (See path.py). For each Path object, you can get an Nx2 array of vertices from its vertices member. You can also use the iter_segments method to iterate through each of its vertices, but that's primarily only useful when there may be bezier curves in the path, which there won't be in the case of contours. Missing docstrings is definitely a problem that will need to be worked on. Cheers, Mike [EMAIL PROTECTED] wrote: Hello, I'm using a svn version of matplotlib and the API changed for contour. I want to have the coordinate of the contour. Before Eric Firing (I think) gave a solution to do it: val = contour(xRange,yRange,delchi2,[1]) t = asarray(val.collections[0].get_verts()) but now get_verts doesn't exist anymore. I tried to do: cs = contour(a) path = cs.collections[0].get_paths() but I don't know how to use it. Basically I think that I have the contour coordinate but I don't know how to recuperate them. I need it to export them in a data file so it's the reason I want to recuperate them. Thank you for any help N. ps: It's a little bit difficult to access to the help for a method now some, perhaps most, of them are missing a docstring. So it's difficult to understand what it is the meaning of each of them. example: col.get_paths? Type: instancemethod Base Class: type 'instancemethod' String Form:bound method LineCollection.get_paths of matplotlib.collections.LineCollection object at 0x9038a4c Namespace: Interactive File: /usr/lib/python2.5/site-packages/matplotlib/collections.py Definition: col.get_paths(self) Docstring: no docstring - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Basemap, Mercator Projection and pcolor
Rich Fought wrote: Hi, I've successfully plotted gridded data on a basemap cyl projection using pcolor: mp = Basemap(projection=cyl, resolution=l, llcrnrlon=0.0, urcrnrlon=30.0, llcrnrlat=-5.0, urcrnrlat=5.0) pc = mp.pcolor(X, Y, zvalsm, cmap=cm.jet) However, if I simply I change the projection type to merc, adding appropriate lat_ts, I get the projection but the pcolor fails to plot on it: mp = Basemap(projection=merc, lat_ts=0.0, resolution=l, llcrnrlon=0.0, urcrnrlon=30.0, llcrnrlat=-5.0, urcrnrlat=5.0)' pc = mp.pcolor(X, Y, zvalsm, cmap=cm.jet) Any ideas? I am using matplotlib 0.91.2 and basemap 0.9.9 on CentOS 4.0 with Python 2.3. Thanks, Rich Rich: What are X and Y set to? They should be the map projection coorindates of the grid. If they are latitudes and longitudes, this will work for 'cyl' but not 'merc'. For 'merc', you must convert the lats and lons to x and y using x, y = mp(lon, lat) -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX: (303)497-6449 NOAA/OAR/PSD R/PSD1Email : [EMAIL PROTECTED] 325 BroadwayOffice : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Basemap, Mercator Projection and pcolor
Rich: What are X and Y set to? They should be the map projection coorindates of the grid. If they are latitudes and longitudes, this will work for 'cyl' but not 'merc'. For 'merc', you must convert the lats and lons to x and y using x, y = mp(lon, lat) -Jeff Thanks Jeff, that did the trick ... I am working with lats/longs and I assumed that the conversion would be automatic for some reason. Rich - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] pcolor and
Matplotlib users, I've been using pcolor and pcolormesh to plot results from the NCEP Reanalysis. I've noticed that the plotted values are slightly offset. Googling around I see that matlab has this quality, which I assume matplotlib inherited. # If your georeferenced image is in lat/long coordinates (i.e. each data row is along a line of constant latitude, each column a line of equal longitude), ... you MUST remember to offset your coordinates by one-half of the pixel spacing. This is because of the different behaviors of p_color and image when given the same data. 1. image will center the drawn (i,j) pixel on the (i,j)th entry of the X/Y matrices. 2. p_color with shading flat will draw a panel between the (i,j), (i+1,j),(i+1,j+1),(i,j+1) coordinates of the X/Y matrices with a color corresponding to the data value at (i,j). Thus everything will appear shifted by one half a pixel spacing. and % Since the grid is rectangluar in lat/long (i.e. not % really a projection at all, althouhg it is included in % m_map under the name 'equidistant cyldindrical'), we % don't want to use the 'image' technique. Instead... % Create a grid, offsetting by half a grid point to account % for the flat pcolor [Plg,Plt]=meshgrid(Plon-0.25,Plat+0.25); The data I'm using uses polar grids centered on +-90.0 which give a latitude array as such [-90. -87.5 -85. -82.5 -80. -77.5 -75. -72.5 -70. -67.5 -65. -62.5 -60. -57.5 -55. -52.5 -50. -47.5 -45. -42.5 -40. -37.5 -35. -32.5 -30. -27.5 -25. -22.5 -20. -17.5 -15. -12.5 -10. -7.5 -5. -2.5 0.2.5 5.7.5 10. 12.5 15. 17.5 20. 22.5 25. 27.5 30. 32.5 35. 37.5 40. 42.5 45. 47.5 50. 52.5 55. 57.5 60. 62.5 65. 67.5 70. 72.5 75. 77.5 80. 82.5 85. 87.5 90. ] Is there a simple way to shift this data so my global plots look correct? So far my results result in an empty line along the south pole or I end up with an extra latitude which pcolor doesn't like. Thanks, Mike - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] pcolor and
mbauer wrote: Matplotlib users, I've been using pcolor and pcolormesh to plot results from the NCEP Reanalysis. I've noticed that the plotted values are slightly offset. Googling around I see that matlab has this quality, which I assume matplotlib inherited. # If your georeferenced image is in lat/long coordinates (i.e. each data row is along a line of constant latitude, each column a line of equal longitude), ... you MUST remember to offset your coordinates by one-half of the pixel spacing. This is because of the different behaviors of p_color and image when given the same data. 1. image will center the drawn (i,j) pixel on the (i,j)th entry of the X/Y matrices. 2. p_color with shading flat will draw a panel between the (i,j), (i+1,j),(i+1,j+1),(i,j+1) coordinates of the X/Y matrices with a color corresponding to the data value at (i,j). Thus everything will appear shifted by one half a pixel spacing. and % Since the grid is rectangluar in lat/long (i.e. not % really a projection at all, althouhg it is included in % m_map under the name 'equidistant cyldindrical'), we % don't want to use the 'image' technique. Instead... % Create a grid, offsetting by half a grid point to account % for the flat pcolor [Plg,Plt]=meshgrid(Plon-0.25,Plat+0.25); The data I'm using uses polar grids centered on +-90.0 which give a latitude array as such [-90. -87.5 -85. -82.5 -80. -77.5 -75. -72.5 -70. -67.5 -65. -62.5 -60. -57.5 -55. -52.5 -50. -47.5 -45. -42.5 -40. -37.5 -35. -32.5 -30. -27.5 -25. -22.5 -20. -17.5 -15. -12.5 -10. -7.5 -5. -2.5 0.2.5 5.7.5 10. 12.5 15. 17.5 20. 22.5 25. 27.5 30. 32.5 35. 37.5 40. 42.5 45. 47.5 50. 52.5 55. 57.5 60. 62.5 65. 67.5 70. 72.5 75. 77.5 80. 82.5 85. 87.5 90. ] Is there a simple way to shift this data so my global plots look correct? So far my results result in an empty line along the south pole or I end up with an extra latitude which pcolor doesn't like. Thanks, Mike Mike: From the pcolor docstring: X and Y, if given, specify the (x,y) coordinates of the colored quadrilaterals; the quadrilateral for C[i,j] has corners at (X[i,j],Y[i,j]), (X[i,j+1],Y[i,j+1]), (X[i+1,j],Y[i+1,j]), (X[i+1,j+1],Y[i+1,j+1]). Ideally the dimensions of X and Y should be one greater than those of C; if the dimensions are the same, then the last row and column of C will be ignored. So it may be easier to modify your data (by averaging adjacent values to they reflect the mid-point of each grid box) than to modify the vertices. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX: (303)497-6449 NOAA/OAR/PSD R/PSD1Email : [EMAIL PROTECTED] 325 BroadwayOffice : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] [newbie] live plots of multiple lines
Chris Withers wrote: Matthias Michler wrote: plot([x1], [y1], bo, [x2], [y2], r+) This didn't work :-S - the first time I call show(), execution never comes back to my script so the code never gets to plot any further points Okay, thanks to Ryan, I now have this point fixed, however, with the following code: ion() i = 1 while i 5: plot([i],[i],'go',[i],[i+2],'ro') print i i+=1 sleep(0.5) draw() - there are no lines between the points, how do I get the lines to show? - how would I pass keyword parameters such as label or use other methods such as plot_date? Also, when the above script finishes, I get: Fatal Python error: PyEval_RestoreThread: NULL tstate This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. What does that mean? cheers, Chris -- Simplistix - Content Management, Zope Python Consulting - http://www.simplistix.co.uk - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] variable line thickness in a plot
Hi, does anyone know of a way to create lines with variable thickness and color when doing a plot? Basically, I'd like to have a third dimension represented using thickness. The API for the plot function states that the line thickness can only be a single floating point number. Thanks - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] variable line thickness in a plot
On Tue, Mar 11, 2008 at 12:45:21PM -0700, eliss wrote: Hi, does anyone know of a way to create lines with variable thickness and color when doing a plot? Basically, I'd like to have a third dimension represented using thickness. The API for the plot function states that the line thickness can only be a single floating point number. Thanks - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users I don't know if this is the easiest way, but it can be done with clever use of fill: from pylab import * x = linspace(0,10,101) y = cos(x) z = sin(3*x)+2 zn = 0.05*z xs, ys = mlab.poly_between(x, y-zn, y+zn) fill(xs, ys) show() Best Regards -- Troels Kofoed Jacobsen [EMAIL PROTECTED] tel: +45 20880798 - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] variable line thickness in a plot
On Tue, Mar 11, 2008 at 12:45:21PM -0700, eliss wrote: The API for the plot function states that the line thickness can only be a single floating point number. Really? Try plot([1,2,3], lw=math.pi) cheers, steve - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] variable line thickness in a plot
On 3/11/08, Troels Kofoed Jacobsen [EMAIL PROTECTED] wrote: On Tue, Mar 11, 2008 at 12:45:21PM -0700, eliss wrote: Hi, does anyone know of a way to create lines with variable thickness and color when doing a plot? Basically, I'd like to have a third dimension represented using thickness. The API for the plot function states that the line thickness can only be a single floating point number. Thanks I don't know if this is the easiest way, but it can be done with clever use of fill: from pylab import * x = linspace(0,10,101) y = cos(x) z = sin(3*x)+2 zn = 0.05*z xs, ys = mlab.poly_between(x, y-zn, y+zn) fill(xs, ys) show() Best Regards Thanks for the reply. I couldn't find the poly_between function in mlab. I imported my mlab, and did dir(mlab) but that method doesn't show up in there. I tried redownloading the latest version of matplotlib as well. Am I missing a library? - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] variable line thickness in a plot
On Tue, Mar 11, 2008 at 01:23:04PM -0700, eliss wrote: On 3/11/08, Troels Kofoed Jacobsen [EMAIL PROTECTED] wrote: On Tue, Mar 11, 2008 at 12:45:21PM -0700, eliss wrote: Hi, does anyone know of a way to create lines with variable thickness and color when doing a plot? Basically, I'd like to have a third dimension represented using thickness. The API for the plot function states that the line thickness can only be a single floating point number. Thanks I don't know if this is the easiest way, but it can be done with clever use of fill: from pylab import * x = linspace(0,10,101) y = cos(x) z = sin(3*x)+2 zn = 0.05*z xs, ys = mlab.poly_between(x, y-zn, y+zn) fill(xs, ys) show() Best Regards Thanks for the reply. I couldn't find the poly_between function in mlab. I imported my mlab, and did dir(mlab) but that method doesn't show up in there. I tried redownloading the latest version of matplotlib as well. Am I missing a library? References 1. mailto:[EMAIL PROTECTED] - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users I have version 0.91.2 of matplotlib and for me the function is there. (I found it in the fill_between.py example) -- Troels Kofoed Jacobsen [EMAIL PROTECTED] tel: +45 20880798 - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] variable line thickness in a plot
On Tue, Mar 11, 2008 at 01:23:55PM -0700, eliss wrote: On 3/11/08, Steve Schmerler [EMAIL PROTECTED] wrote: On Tue, Mar 11, 2008 at 12:45:21PM -0700, eliss wrote: The API for the plot function states that the line thickness can only be a single floating point number. Really? Try plot([1,2,3], lw=math.pi) cheers, steve Sorry, I don't get your point. math.pi is just a single floating point number. How can I use that to create lines with variable thickness? Ah sorry for the noise, I didn't read your message well. I somehow thought you ment an *integer* rather than a float. So, I'm not sure whether you want a single line that changes width and color or several lines that change. In the latter case you could of course just loop over your properties. Something like x = linspace(0,3,50) for w in [0,1,2,3,4,5]: plot(x, sin(x*w), lw=w, color=(w/5.0,0,(5-w)/5.0)); If you don't want that, then the example from Troels Kofoed Jacobsen will be a nice way to go. Didn't know about mlab.poly_between. Didn't find it in the CHANGELOG. cheers, steve - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users