[Matplotlib-users] basemap toolkit: project graphics file given in lon-lat
Dear all, I would like to project a graphics file of some colour coded geo data that is already given in lat-lon with corners specified in lat-lon onto a map. The projection of the result should be flexible. In the end the resulting plot shows a section of the earth, either from a satallite perspective (ortho) or some convenient projection. All examples I found seem to be doing different things or special cases that I have trouble to generalize or modify. These examples transform the data from some (often unpecified) system to a coordinate system that suites the chosen projection. But the fact that the geo data file is given in lat-lon with corners must simplify everything and should make the chosen projection arbitrary. The resolution of the data file must also be arbitrary and should not appear in the code. I do not see why the final projection should require beforehand a change of the geo-data coordinate system *by hand* i.e. typing in the transform formulas and extracting pixel sizes. I would have thought that to avoid this is the whole point of using map toolkits. I imagine a function that takes the parameters - datafile, alternatively an array with a colour value or RGB for each lon-lat coordinate - its lon-lat corners, - a basemap map-object i want the data projected onto - and the projection specifier (possibly with desired corners if different from the maps corners) that determines how i want to see the the resulting piece of the globe. Could someone explain to me (a python newbie) what the sequence of steps/functions would have to be or which predefined methods are doing this. Regards Daniel -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Adding Arrows to Polar Plot
Dear All, I am not very much into matplotlib, so please bear with me if I am asking a trivial question. I put together this small snippet with the help I got on the mailing list and using the arrow example at http://bit.ly/cI9dqj . My problem is (or at least I believe it to be) the fact that I am messing up the coordinates or rather: I am generating a x and y coordinates in the range [-1,1], but I eventually resort to polar coordinates. It all goes fine till I try adding arrows to the image (then I think about Cartesian coordinates) and the result is quite a mess. Bottom line: any ideas about how to use arrows in a polar plot? Many thanks Lorenzo ## #!/usr/bin/env python See pcolor_demo2 for a much faster way of generating pcolor plots from __future__ import division from pylab import * # make these smaller to increase the resolution dx, dy = 0.005, 0.005 x = arange(-1.0, 1.0, dx) y = arange(-1.0, 1.0, dy) X,Y = meshgrid(x, y) # function defined in polar coordinate def func5(theta, r): y = r*np.sin(theta) theta=np.arcsin(y) return np.cos(theta) def func6(theta, r): y = r*np.sin(theta) theta=np.arcsin(y) return np.abs(sin(theta)) def func7(theta, r): y = r*np.sin(theta) theta=np.arcsin(y) return np.abs(cos(theta)) R=1. n_theta, n_r = 360, 100 # coordinates of the mesh theta = np.linspace(0, 2*np.pi, n_theta+1) r = np.linspace(0., R, n_r + 1) dr, dtheta = r[1]-r[0], theta[1]-theta[0] # cooridnate for the data point theta_d = np.arange(dtheta/2., 2*np.pi, dtheta) r_d = np.arange(dr/2., R, dr) TT, RR = meshgrid(theta_d, r_d) # Z = func6(TT, RR) Z = func7(TT, RR) ax=subplot(1,1,1, projection=polar, aspect=1.) ax.pcolormesh(theta, r, Z) # ax.set_xlabel('Model complexity ---') ax.set_yticklabels([]) ax.set_xticklabels([]) ax.grid(False) # show() arr = Arrow(0, 0, .3, .3, edgecolor='white') # Get the subplot that we are currently working on ax = gca() # Now add the arrow ax.add_patch(arr) # We should be able to make modifications to the arrow. # Lets make it green. arr.set_facecolor('g') savefig(test.pdf) clf() -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] 3d plot without marker edge
Hi, I have a 3d plot that I am trying to plot and I can not get rid of the marker edge. an example would help Bryn -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] 3d plot without marker edge
On Fri, Oct 15, 2010 at 3:10 AM, Robert Fenwick robert.fenw...@irbbarcelona.org wrote: I have a 3d plot that I am trying to plot and I can not get rid of the marker edge. an example would help What have you tried -- if line is a Line3D object, the following should work: line.set_markeredgecolor('None') Note that 'None' is a string here, not the python object None. This is because None in matplotlib properties means do the default, ie the default value specified in matplotlibrc http://matplotlib.sourceforge.net/users/customizing.html JDH -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Adding Arrows to Polar Plot
On Fri, Oct 15, 2010 at 9:33 PM, Lorenzo Isella lorenzo.ise...@gmail.com wrote: arr = Arrow(0, 0, .3, .3, edgecolor='white') # Get the subplot that we are currently working on ax = gca() # Now add the arrow ax.add_patch(arr) I recommend you to use the annotate command. annotate(, xy=(0, 0), xytext=(0.3, 0.3), arrowprops=dict(fc=g)) see http://matplotlib.sourceforge.net/users/annotations_guide.html#annotating-with-arrow Regards, -JJ -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] user group video
On Thu, Oct 14, 2010 at 2:07 PM, Carl Karsten c...@personnelware.com wrote: yep - thanks. Not exactly how I remember it from the talk. wonder where the story got changed. Hey Carl -- I added the talk video link on the mpl website http://carlfk.blip.tv/file/2557425 The dolphins story you were referring to starts around 39:30. Not sure how your memory of the story got deformed :-) JDH -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] 3d plot without marker edge
Since you are talking about markers, I assume that you made the plot with the scatter() function. The scatter() function creates the appropriate collection of patches (polygon, circle, etc.) depending on what the marker style was passed to it. As such, the normal 'marker*' properties do not work, as there is just a collection patches that is being drawn. So the properties that you are looking for in your situation are here: http://matplotlib.sourceforge.net/api/collections_api.html#matplotlib.collections.PatchCollection I believe that the property you are looking for is 'edgewidth'. E.g. (and I think this is right, but not where I can test right now): the_artist.set_edgewidth(0.0) Which I believe will work, or you may have to do the_artist.set_edgewidths((0.0,)) But anyway, hopefully this is enough to set you on your way. On Fri, Oct 15, 2010 at 4:10 AM, Robert Fenwick robert.fenw...@irbbarcelona.org wrote: Hi, I have a 3d plot that I am trying to plot and I can not get rid of the marker edge. an example would help Bryn -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Daniel Hyams dhy...@gmail.com -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] 3d plot without marker edge
Ugh, if I could only undo an email send 20 seconds after I hit go ;) If setting 'edgewidths' to 0 doesn't work, try setting 'edgecolors' to 'None' as per JDH's suggestion above, which is the same suggestion as mine except for the marker part of the property is removed. On Fri, Oct 15, 2010 at 10:32 AM, Daniel Hyams dhy...@gmail.com wrote: Since you are talking about markers, I assume that you made the plot with the scatter() function. The scatter() function creates the appropriate collection of patches (polygon, circle, etc.) depending on what the marker style was passed to it. As such, the normal 'marker*' properties do not work, as there is just a collection patches that is being drawn. So the properties that you are looking for in your situation are here: http://matplotlib.sourceforge.net/api/collections_api.html#matplotlib.collections.PatchCollection I believe that the property you are looking for is 'edgewidth'. E.g. (and I think this is right, but not where I can test right now): the_artist.set_edgewidth(0.0) Which I believe will work, or you may have to do the_artist.set_edgewidths((0.0,)) But anyway, hopefully this is enough to set you on your way. On Fri, Oct 15, 2010 at 4:10 AM, Robert Fenwick robert.fenw...@irbbarcelona.org wrote: Hi, I have a 3d plot that I am trying to plot and I can not get rid of the marker edge. an example would help Bryn -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Daniel Hyams dhy...@gmail.com -- Daniel Hyams dhy...@gmail.com -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Marker types in 3d plots
Right, there is only a subset of marker styles supported in the scatter function, both 2D and 3D. This is because, behind the scenes, it's drawing all of the symbols as patches. See http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.scatter On Fri, Oct 15, 2010 at 10:43 AM, R. Bryn Fenwick robert.fenw...@irbbarcelona.org wrote: Marker types in 3d plots Hi, A few problems with marker types in 3D plots. I can use o and ^ and +. However I can not use . or , it seems a bit odd to me however I get the below error. It should be possible to repeat this with the following input Traceback (most recent call last): File test.py, line 16, in module ax.scatter(xs, ys, zs, c=c, marker=m) File /Library/Frameworks/Python.framework/Versions/2.6/lib/ python2.6/site-packages/mpl_toolkits/mplot3d/axes3d.py, line 1019, in scatter patches = Axes.scatter(self, xs, ys, *args, **kwargs) File /Library/Frameworks/Python.framework/Versions/2.6/lib/ python2.6/site-packages/matplotlib/axes.py, line 5719, in scatter raise ValueError('Unknown marker symbol to scatter') ValueError: Unknown marker symbol to scatter import numpy as np from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt def randrange(n, vmin, vmax): return (vmax-vmin)*np.random.rand(n) + vmin fig = plt.figure() ax = fig.add_subplot(111, projection='3d') n = 100 #for c, m, zl, zh in [('r', '+', -50, -25), ('b', '^', -30, -5)]: for c, m, zl, zh in [('r', '+', -50, -25), ('b', '.', -30, -5)]: xs = randrange(n, 23, 32) ys = randrange(n, 0, 100) zs = randrange(n, zl, zh) ax.scatter(xs, ys, zs, c=c, marker=m) ax.set_xlabel('X Label') ax.set_ylabel('Y Label') ax.set_zlabel('Z Label') plt.show() -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Daniel Hyams dhy...@gmail.com -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Best way to use Excel Data
On 10/14/10 9:52 PM, Alessio Civ wrote: Let' put things this way: if you have to work with many records, it is better if you have a database. pyTables is worth a look, too http://www.pytables.org/moin -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 -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] closing figure inside a callback seg faults
I want to do something like this: import matplotlib.pyplot as plt def onclick(event): if event.button==1: plt.close() fig = plt.gcf() cid = fig.canvas.mpl_connect('button_press_event', onclick) plt.show() I've tried several variations on this theme, but all of them cause crashes. Am I missing something? I'm using 1.0.0 with WXAgg thanks, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] closing figure inside a callback seg faults
On 10/15/10 5:16 PM, Paul Ivanov wrote: I want to do something like this: import matplotlib.pyplot as plt def onclick(event): if event.button==1: plt.close() fig = plt.gcf() cid = fig.canvas.mpl_connect('button_press_event', onclick) plt.show() I've tried several variations on this theme, but all of them cause crashes. Am I missing something? I'm using 1.0.0 with WXAgg thanks, I don't know if MPL events do anything like this, but since you are using wx, you could probably use wx.CallAfter() (or wx.CallLater(), call one of those in your callback,a nd tehn have the function called close the figure. -Chris -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] basemap toolkit: project graphics file given in lon-lat
Dear Daniel, to give the corners of an array, some matplotlib plotting functions have the extent keyword, e.g. contour and imshow. You can use this to put your data on the map. However, the functions of the Basemap class do not support this functionality. Basemap.imshow overwrites the extent keyword (see docstring). A workaround is to call matplotlib.pyplot.imshow instead, to draw on your Basemap map: map = Basemap(projection='...', ...) map.drawcoastlines() extent = reduce(lambda x,y: x+y, map([lon0,lon1],[lat0,lat1]) matplotlib.pyplot.imshow(data, extent=extent) You can also create an axes instance first, to have more control over your plot. To your second question: Since the real globe is a 3d sphere with longitude and latitude and your image is a 2d map with x,y coordinates, you need some rule how to transform longitude and latitude to your x,y system. This rules are the different projections. The main idea of basemap is to help you with this projection by calling x,y = map(lons, lats). So, I guess your are using basemap wrong, if you have to change the coordinates *by hand*. If you need more help, you should give a small example where your problem occurs. Best Regards, Gerrit - Original Message - From: Daniel Fulger daniel.ful...@web.de Date: Friday, October 15, 2010 6:20 pm Subject: [Matplotlib-users] basemap toolkit: project graphics file given in lon-lat To: matplotlib-users@lists.sourceforge.net Dear all, I would like to project a graphics file of some colour coded geo data that is already given in lat-lon with corners specified in lat-lon onto a map. The projection of the result should be flexible. In the end the resulting plot shows a section of the earth, either from a satallite perspective (ortho) or some convenient projection. All examples I found seem to be doing different things or special cases that I have trouble to generalize or modify. These examples transform the data from some (often unpecified) system to a coordinate system that suites the chosen projection. But the fact that the geo data file is given in lat-lon with corners must simplify everything and should make the chosen projection arbitrary. The resolution of the data file must also be arbitrary and should not appear in the code. I do not see why the final projection should require beforehand a change of the geo-data coordinate system *by hand* i.e. typing in the transform formulas and extracting pixel sizes. I would have thought that to avoid this is the whole point of using map toolkits. I imagine a function that takes the parameters - datafile, alternatively an array with a colour value or RGB for each lon-lat coordinate - its lon-lat corners, - a basemap map-object i want the data projected onto - and the projection specifier (possibly with desired corners if different from the maps corners) that determines how i want to see the the resulting piece of the globe. Could someone explain to me (a python newbie) what the sequence of steps/functions would have to be or which predefined methods are doing this. Regards Daniel -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Download new Adobe(R) Flash(R) Builder(TM) 4 The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly Flex(R) Builder(TM)) enable the development of rich applications that run across multiple browsers and platforms. Download your free trials today! http://p.sf.net/sfu/adobe-dev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users