Re: [Matplotlib-users] Backend Agg - problem!
On Thu, 14 Feb 2008, John Hunter apparently wrote: import numpy as np import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt x, y = np.random.rand(2,100) fig = plt.figure() ax = fig.add_subplot(111) ax.plot(x, y, marker='o', linestyle='', markerfacecolor='green') ax.set_title('Some random dots') ax.set_xlabel('x') ax.set_ylabel('y') ax.grid(True) fig.savefig('myplot.png', dpi=100) plt.show() Does that ``show`` command have any effect? (I know the effect for TkAgg.) I tried clicking the ``show`` help at URL:http://matplotlib.sourceforge.net/ but that directs to URL:http://matplotlib.sourceforge.net/matplotlib.pyplot.html#-show which does not exist. Thank you, 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] Read/write data from matlab?
Hi, On Thu, Feb 14, 2008 at 3:10 PM, Neal Becker [EMAIL PROTECTED] wrote: Is there a way for me to read/write data to/from matlab? I know nothing about matlab, but if I need a colleague to send me some data, what should I tell her about how to save it from matlab so that I can import it into matplotlib/numpy? There's scipy.io.loadmat . As far as I know it reads all valid mat files, but happy to be corrected! Matthew - 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 and omerc
On Wed, Feb 13, 2008 at 2:16 PM, Jeff Whitaker [EMAIL PROTECTED] wrote: Evan Mason wrote: Hi Jeff Here are the corners: lon_corners = N.array([-4.09300764,-35.76003475,-43.72330207, -12.05627497]) lat_corners = N.array([41.90278813, 49.2136974, 14.7209971, 7.41008784]) The reason for the differences is that the matlab script is very fiddly, lots of trial and error to get the grid in the right place. The attraction of using basemap is it allows me to specify the corners, so that I have it right first time, that's the idea anyway. That would be great if you could turn off that rotation, maybe a keyword True/False Thanks, Evan Evan: I've changed Basemap in svn so you can set 'no_rot=True' when creating a Basemap instance for the 'omerc' projection to get what you want. If you don't feel like upgrading (since that requires upgrading matplotlib to svn head at the same time), this will work in the version you have: from matplotlib.toolkits.basemap import Basemap, pyproj from pylab import * p = pyproj.Proj(lon_2=-27.8,lon_1=-19.9,no_rot=True,proj='omerc',\ lat_2=11.0,lat_1=45.5) xmax,ymax = p(-4.093,41.9027) # upper right corner xmin,ymin = p(-43.723,14.721) # lower left corner x = linspace(xmin,xmax,35) y = linspace(ymin,ymax,35) x, y = meshgrid(x,y) lonr,latr = p(x,y, inverse=True) m = Basemap(llcrnrlon=-60,llcrnrlat=5,\ urcrnrlon=15,urcrnrlat=60,resolution='i') m.drawcoastlines() m.scatter(lonr.flatten(),latr.flatten(),5,marker='o') m.drawmeridians(arange(-60,21,10),labels=[0,0,0,1]) m.drawparallels(arange(0,61,10),labels=[1,0,0,0]) show() Let me know if this fixes it for you. -Jeff On Feb 13, 2008 12:56 PM, Jeff Whitaker [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Evan Mason wrote: Hi Jeff By losing the memory I mean that the grid is no longer rotated; that the rotation I introduced through lat1, lon1, lat2, lon2 is lost. If you look at the latitude of the two bottom corners you see that they are the same, they should be different. In other words, I want my great circle not to be the equator or a meridian, instead I want it to be between lat1, lon1, lat2, lon2. See for example: http://erg.usgs.gov/isb/pubs/MapProjections/projections.html#mercator Attached is a png from the matlab script. Here you can see the rotation that I am looking for. The latitude of the two bottom corners is different, unlike what happens presently with my basemap script. Thanks, Evan Evan: OK, I was confused by your use of the term 'losing the memory'. Basemap didn't lose the rotation, it never had it in the first place. It looks like matlab and Basemap define the projection regions differently. They both are right, but are showing you different regions of the same projection. The difference is that proj4 (and therefore Basemap) automatically rotates the y axis to lie along true north. I think I know how to modify Basemap to display the region you want, by turning off that rotation. Can you send me the lat/lon values of the 4 corners of the region that matlab produces? -Jeff P.S. I don't know if this is relevant or not, but you appear to be giving matlab different points to define the center of the projection than you did in Basemap (the lons you gave matlab are -23.75,-28.25, the lons you give in Basemap are -27.8 and 19.9). On Feb 13, 2008 10:48 AM, Jeff Whitaker [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Evan Mason wrote: Thanks for the replies. The map you produced, Jeff, looks as it should. However, I am trying to make an ocean model grid, and so I require two 2d arrays of lon and lat, at my desired grid spacing. This is why I try the steps: dl = 2. nx = int((M.xmax - M.xmin) / dl) + 1 ny = int((M.ymax - M.ymin) / dl) + 1 lonr, latr = M.makegrid(nx, ny) - it seems to be here that it loses 'memory' of omerc projection that I specified, and maybe there is a bug here? Evan: Why do you say it 'loses' memory of the projection? The values look fine to me - they are just equally spaced points in map projection coordinates that cover the map projection region. Take a look at M = Basemap(projection = 'omerc', \ resolution = 'l', \ llcrnrlon = -43.7, \ llcrnrlat = 14.7,\
[Matplotlib-users] automatically choose line markers/styles?
Can matplotlib automatically choose line styles and/or markers for a group of plots? - 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] automatically choose line markers/styles?
Alan G Isaac wrote: On Thu, 14 Feb 2008, Neal Becker apparently wrote: Can matplotlib automatically choose line styles and/or markers for a group of plots? http://matplotlib.sourceforge.net/matplotlibrc Although I prefer to pass in a dict of keyword arguments. Not sure what you're telling me here. I'm thinking: I can get nice default grid with grid() I can get nice default legend with legend() Can I get nice default line styles and markers, automatically set up with matching legend? Automatically chosen? I don't want to have to go through and manually choose each marker and line style. - 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] strange axis limits behavior after using aspect_ratio
Michael Droettboom wrote: You can call ax.apply_aspect() to do the aspect ratio calculations -- seems to work for me here with your example. The aspect ratio code has always felt like a bit of a black art to me (it's a seemingly necessarily complex piece of code). Maybe someone else can answer -- is there a reason not to call apply_aspect() from set_aspect() besides a little extra computation? It obviously will still have to be called from draw (in case the figure size changes), but does it hurt to do it one extra time? Mike, Mark, I answered this a minute ago before seeing the present set of messages, and without working through it carefully. Now I see that, indeed, the simple default version of the call (no arguments) is identical to the version in the draw method. It is possible that it would not actually hurt to call it in set_aspect, but I would need to look at that quite carefully, which I can't do right now. Maybe this evening or this weekend at the latest. And, the answer may be different for svn versus the present release; I will consider only svn. I agree entirely that the aspect ratio code is complex, and painful to work with. It took a long time to get it to its present state--make it do most things reasonably; a case is found where it doesn't work; fix that; another problem pops up; fix that; and on and on--but throughout there has been a sense that surely there must be a better way! The torture test for the aspect ratio code is making a plot (or worse, a set of subplots with shared axes) and then using the toolbar box-select and the pan/zoom control and the display window corner to manipulate it every which way. Then call set_aspect with a different setting and make sure it redraws sensibly, and do it all over again. Eric Cheers, Mike Mark Bakker wrote: Hello - As reported in an earlier post, when setting aspect ratio, the axis limits don't get updated correctly it seems. Or maybe I have to make another function call. Very easy example: from pylab import * ax = subplot(211) plot([1,2,3]) ax.set_aspect('equal',adjustable='datalim') print ax.get_xlim() # Gives you (0.0, 2.0), which is incorrect, as the data limits have been stretched. draw() print ax.get_xlim() # Gives (-1.8243394308943093, 3.8243394308943093) or something like it, which is correct I don't want to call draw, so is there some other function I can call to update the axis limits? Should that function be called automatically from set_aspect ? I am using mpl 0.92.1. Thanks, Mark - 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] Backend Agg - problem!
On Thu, Feb 14, 2008 at 9:17 AM, Alan G Isaac [EMAIL PROTECTED] wrote: On Thu, 14 Feb 2008, John Hunter apparently wrote: import numpy as np import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt ...snip fig.savefig('myplot.png', dpi=100) plt.show() Does that ``show`` command have any effect? (I know the effect for TkAgg.) I tried clicking the ``show`` help at In this case no, since we are using an image backend. But if we want the script to be robust in the presence of different use directives, eg matplotlib.use('TkAgg') then it is good to have the show in there. JDH - 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