[Matplotlib-users] twinx and twiny cannot remove yticklabels

2015-11-03 Thread Evan Mason
I want to plot contours on top of an image, using twinx and twiny for the
contour coordinates.  I don't want to show the x- and yticklabels for the
contour coordinates.  I find I can remove the xticklabels, but not the
yticklabels.  There is mention of this problem here:
http://stackoverflow.com/questions/12358890/matplotlib-using-twinx-and-twiny-together-like-twinxy
but I wonder if there is now a solution?

The lines below illustrate the problem.

import matplotlib.pyplot as plt
import numpy as np

x1 = np.arange(10)
y1 = np.arange(20)
data1 = np.arange(x1.size * y1.size).reshape(y1.size, x1.size)

x2 = np.arange(10, 40)
y2 = np.arange(-20, 10)
data2 = np.sin(np.arange(x2.size * y2.size).reshape(x2.size, x2.size))

fig = plt.figure()

ax = fig.add_subplot(111)
ax.pcolormesh(x1, y1, data1)

ax2 = ax.twinx().twiny()
ax2.contour(x2, y2, data2, colors='k')
plt.setp(ax2.get_xticklabels(), visible=False)

# Neither of the lines below work
#plt.setp(ax2.get_yticklabels(), visible=False)
plt.setp(ax2.axes.yaxis.get_ticklabels(), visible=False)

plt.show()

Thanks!
--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] passing multiple path arguments to make_compound_path

2014-11-27 Thread Evan Mason
Hi, I have several path objects that I want to join together with
make_compound_path.

For example, with p1 and p2:

In [136]: p1
Out[136]: 
Path(array([[-29.85721973, -30.],
   [-29.84752676, -29.77715877],
   [-29.88734508, -29.55431755],
   [-29.97470553, -29.33147632],
   [-30., -29.28831083]]), None)

In [138]: p2
Out[138]: 
Path(array([[-30.,  45.166 ],
   [-29.94756898,  45.09749304],
   [-29.87227011,  45.32033426],
   [-29.84525888,  45.54317549],
   [-29.86787108,  45.76601671],
   [-29.93898847,  45.98885794],
   [-30.,  46.10595725]]), None)

I can do path.Path.make_compound_path(p1, p2) which joins them successfully.
If I have a another path, p3, I can do:
path.Path.make_compound_path(p1, p2,p3), and so on.

However, in my script I never know how many paths I will have, so I'd like
 to put them into some sort of container, and pass that to
 make_compound_path.  I've tried lists:


In [140]: p1p2 = [p1, p2]

In [141]: path.Path.make_compound_path(p1p2)
---
AttributeErrorTraceback (most recent call last)
 in ()
> 1 path.Path.make_compound_path(p1p2)

/usr/lib64/python2.7/site-packages/matplotlib-1.4.2-py2.7-linux-x86_64.egg
/matplotlib/path.py
in make_compound_path(cls, *args)
330 total_length = sum(lengths)
331 
--> 332 vertices = np.vstack([x.vertices for x in args])
333 vertices.reshape((total_length, 2))
334 

AttributeError: 'list' object has no attribute 'vertices'


without success.  Can anybody suggest a way to do this?

Thanks, Evan


--
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] matplotlib.dates date within a loop

2011-03-16 Thread Evan Mason
Hi, I get unexpected behaviour using the script below.  xticks only appear in
the 4th subplot.  If the lines marked ### are moved out of the loop (and edited
so that they are constants), then xticks do appear on each subplot.  Is this a
bug or am I missing something?

I am using matplotlib 1.1.0svn.

Many thanks, Evan


import numpy as np
import datetime as dt
import matplotlib.dates as dates
import matplotlib.pyplot as plt

months= dates.MonthLocator(range(1,13), bymonthday=1, interval=1)
monthsFmt = dates.DateFormatter("%b %Y")
deltad   = 2
delta= dt.timedelta(days=deltad)


plt.close('all')
fig1 = plt.figure(1)
for i in range(4):
date_str = dt.date(i+2,11,1) ###
date_end = dt.date(i+3,3,1) ###
date_range = dates.drange(date_str,date_end,delta) ###
ax = fig1.add_subplot(2,2,i+1)
ax.plot_date(date_range,np.sin(date_range))
ax.xaxis.set_major_locator(months)
ax.xaxis.set_major_formatter(monthsFmt)

plt.show()





--
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap and clim, has this changed in 0.99

2009-09-29 Thread Evan Mason
On Tue, Sep 29, 2009 at 7:12 PM, Jeff Whitaker  wrote:
> Evan Mason wrote:
>>
>> Hi, I've just upgraded to mpl 0.99 (from svn) and Basemap (also from svn).
>>
>>
>>
>
> Evan:  I believe Ryan May just fixed this yesterday - so if you update
> basemap from svn again it should work.
>
> -Jeff
>>
>> It seems that plt.clim(vmin,vmax) no longer works with Basemap
>> objects.  Here is an example, which before used to work:
>>
>>
>> In [92]: M.pcolormesh(x, y, a_var,cmap=cm)
>> Out[92]: 
>>
>> In [93]: plt.clim(-10,10)
>>
>> ---
>> RuntimeError                              Traceback (most recent call
>> last)
>>
>> /home/emason/pytools/fig_thesis_ssh_variance_prime_month.py in ()
>> > 1
>>      2
>>      3
>>      4
>>      5
>>
>> /usr/lib64/python2.6/site-packages/matplotlib/pyplot.pyc in clim(vmin,
>> vmax)
>>   1379     im = gci()
>>   1380     if im is None:
>> -> 1381         raise RuntimeError('You must first define an image, eg
>> with imshow')
>>   1382
>>   1383     im.set_clim(vmin, vmax)
>>
>> RuntimeError: You must first define an image, eg with imshow
>>
>> In [94]:
>>
>>
>>
>> Using plt.pcolormesh there's no problem.  Has this change been done
>> intentionally?  If so, what is now the recommended way to apply
>> climits to a Basemap plot?
>>
>>
>> Thanks, Evan
>>
>>
>> --
>> Come build with us! The BlackBerry® Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9-12, 2009. Register now!
>> http://p.sf.net/sfu/devconf
>> ___
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
>
> --
> Jeffrey S. Whitaker         Phone  : (303)497-6313
> Meteorologist               FAX    : (303)497-6449
> NOAA/OAR/PSD  R/PSD1        Email  : jeffrey.s.whita...@noaa.gov
> 325 Broadway                Office : Skaggs Research Cntr 1D-113
> Boulder, CO, USA 80303-3328 Web    : http://tinyurl.com/5telg
>
>


Yes, that works now.  Thanks, Evan

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Basemap and clim, has this changed in 0.99

2009-09-29 Thread Evan Mason
Hi, I've just upgraded to mpl 0.99 (from svn) and Basemap (also from svn).



It seems that plt.clim(vmin,vmax) no longer works with Basemap
objects.  Here is an example, which before used to work:


In [92]: M.pcolormesh(x, y, a_var,cmap=cm)
Out[92]: 

In [93]: plt.clim(-10,10)
---
RuntimeError  Traceback (most recent call last)

/home/emason/pytools/fig_thesis_ssh_variance_prime_month.py in ()
> 1
  2
  3
  4
  5

/usr/lib64/python2.6/site-packages/matplotlib/pyplot.pyc in clim(vmin, vmax)
   1379 im = gci()
   1380 if im is None:
-> 1381 raise RuntimeError('You must first define an image, eg
with imshow')
   1382
   1383 im.set_clim(vmin, vmax)

RuntimeError: You must first define an image, eg with imshow

In [94]:



Using plt.pcolormesh there's no problem.  Has this change been done
intentionally?  If so, what is now the recommended way to apply
climits to a Basemap plot?


Thanks, Evan

--
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] mlab.load and non-numeric characters

2009-05-10 Thread Evan Mason
Thanks for that:

def ifmissing(x):
try: return float(x)
except: return np.nan

works just fine.

-Evan



On Sun, May 10, 2009 at 6:59 AM, Ryan May  wrote:

>
>
> On Sat, May 9, 2009 at 8:35 PM, Evan Mason  wrote:
>
>> Hi, I want to use mlab.load to load in some data:
>>
>>
>>1) 2004/02/27 21:51:00   1 2553.51 2553.51
>> -99.N  3.217
>>2) 2004/02/27 22:01:00   2 2553.47 2553.47
>> -99.N  3.217
>>3) 2004/02/27 22:10:59   3 2553.45 2553.45
>> -99.N  3.218
>>4) 2004/02/27 22:20:59   4 2553.46 2553.46
>> -99.N  3.223
>>
>>
>> unfortunately missing values are given as -99.000N, and these cause the
>> following error:
>>
>>
>> In [98]: mlab.load(site_file,skiprows=29,usecols=[4])
>>
>> ---
>> ValueErrorTraceback (most recent call
>> last)
>>
>> /Users/evan/python/tools/fig_NEA_seas_paper_RAPID.py in ()
>> > 1
>>   2
>>   3
>>   4
>>   5
>>
>> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/mlab.pyc
>> in load(fname, comments, delimiter, converters, skiprows, usecols, unpack,
>> dtype)
>>1458 if usecols is not None:
>>1459 vals = splitfunc(line)
>> -> 1460 row = [converterseq[j](vals[j]) for j in usecols]
>>1461 else:
>>1462 row = [converterseq[j](val)
>>
>> ValueError: invalid literal for float(): -99.00N
>>
>>
>> Is there any way around this, apart from editing all the data files to
>> remove every 'N'?
>
>
> Make use of the converters argument:
>
> mlab.load(..., converters={5:fix_func})
>
> Where fix_func is a function that will convert the -99.N values to what
> you're looking for.
>
> Ryan
>
> --
> Ryan May
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma
>
--
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] mlab.load and non-numeric characters

2009-05-09 Thread Evan Mason
Hi, I want to use mlab.load to load in some data:


   1) 2004/02/27 21:51:00   1 2553.51 2553.51
-99.N  3.217
   2) 2004/02/27 22:01:00   2 2553.47 2553.47
-99.N  3.217
   3) 2004/02/27 22:10:59   3 2553.45 2553.45
-99.N  3.218
   4) 2004/02/27 22:20:59   4 2553.46 2553.46
-99.N  3.223


unfortunately missing values are given as -99.000N, and these cause the
following error:


In [98]: mlab.load(site_file,skiprows=29,usecols=[4])
---
ValueErrorTraceback (most recent call last)

/Users/evan/python/tools/fig_NEA_seas_paper_RAPID.py in ()
> 1
  2
  3
  4
  5

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/mlab.pyc
in load(fname, comments, delimiter, converters, skiprows, usecols, unpack,
dtype)
   1458 if usecols is not None:
   1459 vals = splitfunc(line)
-> 1460 row = [converterseq[j](vals[j]) for j in usecols]
   1461 else:
   1462 row = [converterseq[j](val)

ValueError: invalid literal for float(): -99.00N


Is there any way around this, apart from editing all the data files to
remove every 'N'?

Many thanks, Evan
--
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] clabel and rotation

2009-05-08 Thread Evan Mason
Hi, would it be possible to add a keyword to clabel to optionally switch off
the angle fix in contour.py lines 384+?


# Fix angle so text is never upside-down
if rotation > 90:
rotation = rotation - 180.0
if rotation < -90:
rotation = 180.0 + rotation


Something like "clabel(CS, upsidedown=True)" with the default as False would
do it.

I am using clabel to put directional arrows on a streamline contour plot,
and this rotation causes some of the arrows to point the wrong way.  So it
seems it would be a useful feature.  I'm willing to try to do it myself if
somebody could tell me which files I would need to edit in addition to
contour.py?

Many thanks,

Evan
--
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] arrows on contour plots

2009-04-15 Thread Evan Mason
Hi, I want to put arrows onto the contours of a contour plot, the direction
will depend on whether the contour is positive/negative.  Before I try to do
it myself, has anybody written something to do that?

Thanks, Evan
--
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] path and bbox

2008-09-09 Thread Evan Mason
On Tue, Sep 9, 2008 at 2:02 AM, Eric Firing <[EMAIL PROTECTED]> wrote:

> Evan Mason wrote:
>
>> Hi, wonder if anyone can help me with path and bbox.  I have a set of
>> ocean drifter tracks and I want to know if they pass through a particular
>> boxed area.  This is straightforward to do but I wanted to try to do it with
>> matplotlib.transforms and matplotlib.path, which look well-suited to this
>> kind of task using 'intersects_bbox'.
>>
>> The essence of my code is below.  I have a single drifter track (lon, lat)
>> and have defined a boxed area.  At no time does the drifter approach or
>> enter the box - however, the final line,
>>
>>print track.intersects_bbox(bbox)
>>
>> returns True, which it shouldn't.  In total I have 340 tracks.  My code
>> says 74 pass though the box, but by counting there should be only about 9.
>>  Any help appreciated, thanks, Evan
>>
>>
>> import numpy as N
>> import numpy.ma <http://numpy.ma> as MA
>> import matplotlib.transforms as BB
>> import matplotlib.path as PP
>>
>> In [200]: lon
>> Out[200]:
>> masked_array(data = [-15.52 -15.521 -15.541 ..., -- -- --],
>>  mask = [False False False ...,  True  True  True],
>>  fill_value=1e+20)
>>
>> In [201]: lat
>> Out[201]:
>> masked_array(data = [29.2 29.2 29.196 ..., -- -- --],
>>  mask = [False False False ...,  True  True  True],
>>  fill_value=1e+20)
>>
>> In [202]: len(lon), len(lat)
>> Out[202]: (3750, 3750)
>>
>> track = MA.transpose([lon, lat])
>> track = PP.Path(track)
>> bbox = BB.Bbox.from_extents(-15.95, 29.6, -15.9, 29.65)
>>
>> In [206]: print track.intersects_bbox(bbox)
>> 1
>>
>
> Evan,
>
> Can you strip the problem down more?  That is, find one track that is
> misdiagnosed, and then try to find the shortest segment of it that still
> gets misdiagnosed.  You could try subsampling and/or chopping chunks off the
> ends.  If you can get it down to a track with only a few points, so that you
> can email a very short but complete script with illustrative data, that
> would make it much easier for someone to figure out what is going on.
>
> I suspect it is related to the masked values.  If you strip the masked
> points out of your lon and lat arrays, do you get the same result?
> Try making an example with only 3 points, say with the middle one masked,
> and then unmasked.
>
> Eric
>


Eric, I tried what you say about masked values, and that has helped.
However there are still a few tracks that creep through.  Below is a short
script that shows what I mean.  It loads in a matfile with the drifter
track, which I will send to you separately.

# %run path_example.py

import pylab as P
import numpy as N
from scipy import io
from matplotlib.transforms import Bbox as BB
import matplotlib.path as PP

P.close('all')
# Load drifter track (lon, lat)
lonlat = io.loadmat('lonlat')
lon= N.squeeze(lonlat.values()[1])
lat= N.squeeze(lonlat.values()[0])

# Set up box
box = BB.from_extents(-16.6, 28.05, -15.65, 28.15)
bx = [box.xmin, box.xmax, box.xmax, box.xmin, box.xmin]
by = [box.ymin, box.ymin, box.ymax, box.ymax, box.ymin]

track_all = N.transpose([lon, lat])
track_1   = N.transpose([lon[81:295], lat[81:295]])
track_2   = N.transpose([lon[81:290], lat[81:290]])

track_all = PP.Path(track_all)
track_1   = PP.Path(track_1)
track_2   = PP.Path(track_2)

# Test if drifter passes thru box (it doesn't so should be 0)
print track_all.intersects_bbox(box), 'Should be 0'
print   track_1.intersects_bbox(box), 'Should be 0'
print   track_2.intersects_bbox(box), 'Should be 0'

P.figure()
P.plot(lon, lat, 'r', lw=0.3)
P.plot(lon[81:290], lat[81:290], 'g', lw=0.5)
P.plot(bx, by, 'b')

P.show()
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] path and bbox

2008-09-08 Thread Evan Mason
Hi, wonder if anyone can help me with path and bbox.  I have a set of ocean
drifter tracks and I want to know if they pass through a particular boxed
area.  This is straightforward to do but I wanted to try to do it with
matplotlib.transforms and matplotlib.path, which look well-suited to this
kind of task using 'intersects_bbox'.

The essence of my code is below.  I have a single drifter track (lon, lat)
and have defined a boxed area.  At no time does the drifter approach or
enter the box - however, the final line,

print track.intersects_bbox(bbox)

returns True, which it shouldn't.  In total I have 340 tracks.  My code says
74 pass though the box, but by counting there should be only about 9.  Any
help appreciated, thanks, Evan


import numpy as N
import numpy.ma as MA
import matplotlib.transforms as BB
import matplotlib.path as PP

In [200]: lon
Out[200]:
masked_array(data = [-15.52 -15.521 -15.541 ..., -- -- --],
  mask = [False False False ...,  True  True  True],
  fill_value=1e+20)

In [201]: lat
Out[201]:
masked_array(data = [29.2 29.2 29.196 ..., -- -- --],
  mask = [False False False ...,  True  True  True],
  fill_value=1e+20)

In [202]: len(lon), len(lat)
Out[202]: (3750, 3750)

track = MA.transpose([lon, lat])
track = PP.Path(track)
bbox = BB.Bbox.from_extents(-15.95, 29.6, -15.9, 29.65)

In [206]: print track.intersects_bbox(bbox)
1
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] savefig, too many open files

2008-08-15 Thread Evan Mason
Hi

I have a script to plot and save a sequence of png images which I am using
to prepare animations.  This works fine, but I got the following error when
preparing a particularly large number of files:


--- record: 1015
--- record: 1016
/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py:990:
GtkWarning: Failed to read filechooser settings from
"/home/emason/.config/gtk-2.0/gtkfilechooser.ini": Too many open files
Traceback (most recent call last):
  File "fig_bry_paper_anim_vort.py", line 245, in 
  File "/usr/lib/python2.5/site-packages/matplotlib/pyplot.py", line 271, in
savefig
  File "/usr/lib/python2.5/site-packages/matplotlib/figure.py", line 932, in
savefig
  File "/usr/lib/python2.5/site-packages/matplotlib/backend_bases.py", line
1085, in print_figure
  File
"/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py",
line 103, in print_png
  File
"/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py", line
303, in print_png
RuntimeError: Could not open file
/home/emason/Pictures/movies/cb_3km_emb_vort_1016.png


The script is simple, below I show a pared down version of the loop where
the figures are created and saved (but not shown):

for cind in Cind:
P.figure(1)
P.pcolor(plon, plat, pF[cind])
P.colorbar()
P.savefig(fname[cind], dpi=150)
P.close(1)

Does anybody know why I get this error, and can anything be done about it?

Thanks, Evan
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] basemap and omerc

2008-02-14 Thread Evan Mason
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,
&g

Re: [Matplotlib-users] basemap and omerc

2008-02-13 Thread Evan Mason
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 - for the matlab script they are 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

At present, basemap seems to be reverting to a standard mercator projection.

-Evan




On Feb 13, 2008 10:48 AM, Jeff Whitaker <[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,\
>urcrnrlon = -4.0,\
>urcrnrlat  = 41.9,\
>lat_2   = 11.0,\
>lat_1   = 45.5,\
>lon_2  = -27.8,   \
>lon_1  = -19.9)
> dl = 20.
> nx = int((M.xmax - M.xmin) / dl) + 1
> ny = int((M.ymax - M.ymin) / dl) + 1
> lonr, latr,x,y= M.makegrid(nx, ny, returnxy=True)
> M.drawcoastlines()
> M.scatter(x.flatten(), y.flatten(),5,marker='o')
> M.drawparallels(arange(10,51,10))
> M.drawmeridians(arange(-50,1,10))
> show()
> >
> > If you have matlab, the following lines do what I am looking for:
> >
> > incx = 0.00310/2;
> > incy = 0.00306/2;
> > Xstr = -0.275;
> > Xend = 0.275;
> > Ystr  = 0.17;
> > Yend = 0.8;
> > X = [Xstr:incx:Xend];
> > Y = [Ystr:incy:Yend];
> > [XX,YY]= meshgrid(X,Y);
> > [Lonr,Latr] = m_xy2ll(XX,YY);
> > m_proj('Oblique Mercator','lon',[-23.75 -28.25],'lat',[45.5
> > 11],'direction','vertical');
> > plot(Lonr, Latr, 'c.')
>
> Sorry, I don't have matlab - but it looks at first glance like it ought
> to be doing the same thing.
>
> -Jeff
> >
> >
> >
> > -Evan
> >
> >
> >
> >
> >
> > On Feb 13, 2008 5:14 AM, Jeff Whitaker <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> >
> > Evan Mason wrote:
> > > Hi, I am having some problems using the oblique mercator
> > projection in
> > > basemap.  I want to define a rectangular orthogonal grid, rotated
> > > clockwise by about 13 degrees.  I want to define grid cells of
> size,
> > > say, about 20x20 km.  The script I have so far is below.  The
> > problem
> > > is that at some point (the makegrid step) I lose the rotation,
> > as seen
> > > in the plot.
> > >
> > > I'd appreciate any help with this, thanks, Evan
> > >
> > >
> > > from matplotlib.toolkits.basemap import Basemap
> > >
> > > M = Basemap(projection = 'omerc',   \
> > >resolution  = None,   \
> > >llcrnrlon  = -43.7,   \
> > >llcrnrlat   = 14.7,\
> > >urcrnrlon = -4.0,\
> > >urcrnrlat  = 41.9,\
> > >lat_2   = 11.0,\
> > >lat_1   = 45.5,\
> > >lon_2  = -27.8,   \
> > >lon_1  = -19.9)
> > >
> > > dl = 2.
> > > nx = int((M.xmax - M.xmin) / dl) + 1
> > > ny = int((M.ymax - M.ymin) / dl) + 1
> > >
> > > lonr, latr = M.makegrid(nx, ny)
> > >
> > > plot(lonr, latr, 'c.')
> >

Re: [Matplotlib-users] basemap and omerc

2008-02-13 Thread Evan Mason
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?

If you have matlab, the following lines do what I am looking for:

incx = 0.00310/2;
incy = 0.00306/2;
Xstr = -0.275;
Xend = 0.275;
Ystr  = 0.17;
Yend = 0.8;
X = [Xstr:incx:Xend];
Y = [Ystr:incy:Yend];
[XX,YY]= meshgrid(X,Y);
[Lonr,Latr] = m_xy2ll(XX,YY);
m_proj('Oblique Mercator','lon',[-23.75
-28.25],'lat',[45.511],'direction','vertical');
plot(Lonr, Latr, 'c.')



-Evan





On Feb 13, 2008 5:14 AM, Jeff Whitaker <[EMAIL PROTECTED]> wrote:

> Evan Mason wrote:
> > Hi, I am having some problems using the oblique mercator projection in
> > basemap.  I want to define a rectangular orthogonal grid, rotated
> > clockwise by about 13 degrees.  I want to define grid cells of size,
> > say, about 20x20 km.  The script I have so far is below.  The problem
> > is that at some point (the makegrid step) I lose the rotation, as seen
> > in the plot.
> >
> > I'd appreciate any help with this, thanks, Evan
> >
> >
> > from matplotlib.toolkits.basemap import Basemap
> >
> > M = Basemap(projection = 'omerc',   \
> >resolution  = None,   \
> >llcrnrlon  = -43.7,   \
> >llcrnrlat   = 14.7,\
> >urcrnrlon = -4.0,\
> >urcrnrlat  = 41.9,\
> >lat_2   = 11.0,\
> >lat_1   = 45.5,\
> >lon_2  = -27.8,   \
> >lon_1  = -19.9)
> >
> > dl = 2.
> > nx = int((M.xmax - M.xmin) / dl) + 1
> > ny = int((M.ymax - M.ymin) / dl) + 1
> >
> > lonr, latr = M.makegrid(nx, ny)
> >
> > plot(lonr, latr, 'c.')
> > show()
>
> Evan:  I have to admit, I'm not too familiar with the Oblique Mercator
> projection.  What exactly should it look like?
>
> If I plot
>
> M = Basemap(projection = 'omerc',   \
>   resolution  = 'l',   \
>   llcrnrlon  = -43.7,   \
>   llcrnrlat   = 14.7,\
>   urcrnrlon = -4.0,\
>   urcrnrlat  = 41.9,\
>   lat_2   = 11.0,\
>   lat_1   = 45.5,\
>   lon_2  = -27.8,   \
>   lon_1  = -19.9)
> M.drawcoastlines()
> M.drawparallels(arange(10,51,10))
> M.drawmeridians(arange(-50,1,10))
> M.show()
>
> I see a reasonable looking map, but then I don't really know exactly
> what to expect.
>
> It seems that there are two ways to specify oblique mercator in proj4
>
> 1) by specifying 2 points (lon1,lat1), (lon2,lat2) along the central line
> 2) by specifying a central point and an azimuth that passes through the
> central point.
>
> Basemap uses (1), but every example on the web I've seen uses (2).  It
> could be there are bugs in (1), and (2) would produce more reasonable
> results in your case.  If you can give me an example of what your map
> *should* look like,  it would help a lot.
>
> -Jeff
>
>
>
>
> --
> Jeffrey S. Whitaker Phone : (303)497-6313
> NOAA/OAR/CDC  R/PSD1FAX   : (303)497-6449
> 325 BroadwayBoulder, CO, USA 80305-3328
>
>
-
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 and omerc

2008-02-12 Thread Evan Mason
Hi, I am having some problems using the oblique mercator projection in
basemap.  I want to define a rectangular orthogonal grid, rotated clockwise
by about 13 degrees.  I want to define grid cells of size, say, about 20x20
km.  The script I have so far is below.  The problem is that at some point
(the makegrid step) I lose the rotation, as seen in the plot.

I'd appreciate any help with this, thanks, Evan


from matplotlib.toolkits.basemap import Basemap

M = Basemap(projection = 'omerc',   \
   resolution  = None,   \
   llcrnrlon  = -43.7,   \
   llcrnrlat   = 14.7,\
   urcrnrlon = -4.0,\
   urcrnrlat  = 41.9,\
   lat_2   = 11.0,\
   lat_1   = 45.5,\
   lon_2  = -27.8,   \
   lon_1  = -19.9)

dl = 2.
nx = int((M.xmax - M.xmin) / dl) + 1
ny = int((M.ymax - M.ymin) / dl) + 1

lonr, latr = M.makegrid(nx, ny)

plot(lonr, latr, 'c.')
show()
-
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-0.9.8 failure, linux

2007-12-28 Thread Evan Mason
Thank you Jeff.  Setting LD_LIBRARY_PATH works fine as a quick test, though
that leads me to the "ImportError: No module named pkg_resources" problem
that the other recent posters had.  I'll either try setuptools or wait for
0.9.9 to come out - will it be long?

-Evan
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
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-0.9.8 failure, linux

2007-12-28 Thread Evan Mason
Hi all,

Just updated basemap from 0.9.4 to 0.9.8 on Mandriva Linux 2008.  I also
installed basemap-data-fullres-0.9.7.  I've noticed there's a couple of
recent posts about problems (on Macs) with 0.9.8, the solution being to
install setuptools until 0.9.9 comes along; the problem I have is similar to
the posts but not the same, so I'd like to check here before proceeding with
setuptools.

I installed the included geos-2.2.3, then basemap-0.9.8, then
basemap-data-fullres-0.9.7.  However when I now import basemap I get:

In [1]: from matplotlib.toolkits.basemap import Basemap
---
   Traceback (most recent call last)

/home/emason/python/tools/ in ()

/usr/lib/python2.5/site-packages/matplotlib/toolkits/basemap/__init__.py in
()
> 1 from basemap import __doc__, __version__
  2 from basemap import *

/usr/lib/python2.5/site-packages/matplotlib/toolkits/basemap/basemap.py in
()
 29 from matplotlib.cbook import is_scalar, dedent
 30 from shapelib import ShapeFile
---> 31 import _geos, pupynere
 32
 33 # basemap data files now installed in
lib/matplotlib/toolkits/basemap/data

: libgeos_c.so.1: cannot open shared object
file: No such file or directory

Yet the file, in fact a link, libgeos_c.so.1, does exist at the location
(/usr/local/lib) where it is supposed to be:

[EMAIL PROTECTED] lib]# ll
total 44230
-rw-r--r-- 1 root root 28107924 2007-12-28 16:31 libgeos.a
-rw-r--r-- 1 root root   581806 2007-12-28 16:31 libgeos_c.a
-rwxr-xr-x 1 root root  830 2007-12-28 16:31 libgeos_c.la*
lrwxrwxrwx 1 root root   18 2007-12-28 16:31 libgeos_c.so ->
libgeos_c.so.1.1.1*
lrwxrwxrwx 1 root root   18 2007-12-28 16:31 libgeos_c.so.1 ->
libgeos_c.so.1.1.1*
-rwxr-xr-x 1 root root   452162 2007-12-28 16:31 libgeos_c.so.1.1.1*
-rwxr-xr-x 1 root root  790 2007-12-28 16:31 libgeos.la*
lrwxrwxrwx 1 root root   16 2007-12-28 16:31 libgeos.so ->
libgeos.so.2.2.3*
lrwxrwxrwx 1 root root   16 2007-12-28 16:31 libgeos.so.2 ->
libgeos.so.2.2.3*
-rwxr-xr-x 1 root root 13443604 2007-12-28 16:31 libgeos.so.2.2.3*

I'd appreciate any help with this.

Thanks, Evan
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
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] mpl 0.90.1 segmentation fault

2007-10-15 Thread Evan Mason
Hi, when I run the simple_plot.py script in the mpl FAQ I get a seg fault as
follows:

[EMAIL PROTECTED] ~]$ python simple_plot.py --verbose-helpful
matplotlib data path /usr/lib/python2.5/site-packages/matplotlib/mpl-data
$HOME=/home/emason
CONFIGDIR=/home/emason/.matplotlib
loaded rc file /home/emason/.matplotlib/matplotlibrc
matplotlib version 0.90.1
verbose.level helpful
interactive is True
units is False
platform is linux2
numerix numpy 1.0.3.1
LazyValue::init_type
Value::init_type
BinOp::init_type
Point::init_type
Interval::init_type
Bbox::init_type
Func::init_type
FuncXY::init_type
Transformation::init_type
SeparableTransformation::init_type
NonseparableTransformation::init_type
Affine::init_type
init_ns_transforms
Glyph::init_type
FT2Font::init_type
font search path
['/usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf',
'/usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/afm']
loaded ttfcache file /home/emason/.matplotlib/ttffont.cache
_transforms_module::new_value
_transforms_module::new_value
_transforms_module::new_point
Point::Point
_transforms_module::new_value
_transforms_module::new_value
_transforms_module::new_point
Point::Point
_transforms_module::new_bbox
Bbox::Bbox
init_ns_image
Image::init_type
_transforms_module::new_value
Value::~Value
init_ns_backend_agg
backend TkAgg version 8.4
_transforms_module::new_value
_transforms_module::new_value
_transforms_module::new_value
_transforms_module::new_value
_transforms_module::new_value
_transforms_module::new_point
Point::Point
LazyValue::number
BinOp::BinOp
LazyValue::number
BinOp::BinOp
_transforms_module::new_point
Point::Point
_transforms_module::new_bbox
Bbox::Bbox
_transforms_module::new_value
_transforms_module::new_value
_transforms_module::new_point
Point::Point
_transforms_module::new_value
_transforms_module::new_value
_transforms_module::new_point
Point::Point
_transforms_module::new_bbox
Bbox::Bbox
_transforms_module::new_func
_transforms_module::new_func
_transforms_module::new_separable_transformation
BBoxTransformation::BBoxTransformation
SeparableTransformation::SeparableTransformation
Bbox::get_bounds
Bbox::get_bounds
Interval::Interval
Interval::~Interval
Bbox::get_bounds
Value::get
Value::get
RendererAgg::RendererAgg
_transforms_module::new_value
_transforms_module::new_value
_transforms_module::new_point
Point::Point
_transforms_module::new_value
_transforms_module::new_value
_transforms_module::new_point
Point::Point
_transforms_module::new_bbox
Bbox::Bbox
SeparableTransformation::eval_scalars
Transformation::seq_xy_tups
SeparableTransformation::operator
SeparableTransformation::operator
SeparableTransformation::operator
SeparableTransformation::operator
RendererAgg::draw_polygon
GCAgg::GCAgg
GCAgg::points_to_pixels
GCAgg::get_color
GCAgg::antialiased
GCAgg::_set_linecap
GCAgg::_set_joinstyle
GCAgg::_set_dashes
GCAgg::_set_clip_rectangle
GCAgg::_set_clip_path
RendererAgg::_get_rgba_face
RendererAgg::rgb_to_color
RendererAgg::set_clipbox_rasterizer
RendererAgg::set_clipbox_rasterizer done
RendererAgg::draw_polygon DONE
Segmentation fault
[EMAIL PROTECTED] ~]$


I also find that simply importing pylab leads to a long list of output:

[EMAIL PROTECTED] ~]$ python
Python 2.5 (r25:51908, May  7 2007, 13:29:29)
[GCC 4.1.2 20070302 (prerelease) (4.1.2-1mdv2007.1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> import pylab
LazyValue::init_type
Value::init_type
BinOp::init_type
Point::init_type
Interval::init_type
Bbox::init_type
Func::init_type
FuncXY::init_type
Transformation::init_type
SeparableTransformation::init_type
NonseparableTransformation::init_type
Affine::init_type
init_ns_transforms
Glyph::init_type
FT2Font::init_type
_transforms_module::new_value
_transforms_module::new_value
_transforms_module::new_point
Point::Point
_transforms_module::new_value
_transforms_module::new_value
_transforms_module::new_point
Point::Point
_transforms_module::new_bbox
Bbox::Bbox
init_ns_image
Image::init_type
_transforms_module::new_value
Value::~Value
init_ns_backend_agg
>>>

I have removed the /build and /site-packages/matplotlib dirs and reinstalled
mpl a number of times but the result is the same each time.  Can anybody
help with this?

Thanks, Evan
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] installation problems mpl 0.90.1 on Mandriva 2007.1

2007-10-15 Thread Evan Mason
>  matplotlib-0.90.1]#It seems to trip up when expecting a file 'arrayobject.h'
in the /Numeric directory; indeed that file is not there, though Numeric is on
the path.  Numeric came as part of the Mandriva install.
> I'd be grateful for any help with this, thanks in advance, Evan


Ok, just in case someone has similar problems, I fixed this by installing the
python-numeric-devel rpm.  I then got similar problems concerning tk and tcl,
but once again installing the relevant devels sorted it out.

-Evan


-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] installation problems mpl 0.90.1 on Mandriva 2007.1

2007-10-12 Thread Evan Mason
Hi, I am trying to install matplotlib 0.90.1.  I have python 2.5 on a fresh
Mandriva 2007.1 installation.  I have installed numpy and scipy - I think
these are ok, they both import and the tests were largely successful.  I
believe I have all the background packages installed -

   - matplotlib core: zlib, zlib-devel, libpng, libpng-devel, freetype,
   freetype-devel, freetype-utils
   - gtk/gtkagg backend: gtk2-devel, gtk+-devel, pygtk2, glib-devel,
   pygtk2-devel, gnome-libs-devel, pygtk2-libglade
   - tk backend: tcl, tk, tkinter
   - wx/wxagg backends - the wxpython rpms from
wxpython

apart from freetype-utils which I have not been able to find.


With mpl I get the following, having set the path like this:

In [2]: sys.path
Out[2]:
['',
 '/usr/bin',
 '/home/emason',
 '/usr/lib/python2.5/site-packages/numpy/lib',
 '/usr/lib/python2.5/site-packages/scipy/lib',
 '/usr/lib/python25.zip',
 '/usr/lib/python2.5',
 '/usr/lib/python2.5/plat-linux2',
 '/usr/lib/python2.5/lib-tk',
 '/usr/lib/python2.5/lib-dynload',
 '/usr/lib/python2.5/site-packages',
 '/usr/lib/python2.5/site-packages/Numeric',
 '/usr/lib/python2.5/site-packages/PIL',
 '/usr/lib/python2.5/site-packages/gtk-2.0',
 '/usr/lib/python2.5/site-packages/wx-2.6-gtk2-unicode',
 '/usr/lib/python2.5/site-packages/IPython/Extensions',
 '/home/emason/.ipython']
[for PYTHONPATH in .bashrc I defined the paths to numpy/lib and scipy/lib; I
don't know if this is necessary, in any event it made no difference with
these not defined]

When I then try to build I get:

[EMAIL PROTECTED] matplotlib-0.90.1]# python setup.py build
running build
running build_py
copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.linux-i686-2.5
/matplotlib/mpl-data
running build_ext
building 'matplotlib._nc_transforms' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fomit-frame-pointer -march=i586
-mtune=generic -fasynchronous-unwind-tables -g -fPIC -Isrc -I.
-I/usr/local/include -I/usr/include -I. -I/usr/include/python2.5 -c
src/_nc_transforms.cpp -o build/temp.linux-i686-2.5/src/_nc_transforms.o
-DNUMERIC=1 -DVERBOSE
src/_nc_transforms.cpp:13:40: error: Numeric/arrayobject.h: No such file or
directory
src/_nc_transforms.cpp: In member function 'Py::Object
Bbox::update_numerix_xy(const Py::Tuple&)':
src/_nc_transforms.cpp:517: error: 'PyArrayObject' was not declared in this
scope
src/_nc_transforms.cpp:517: error: 'xyin' was not declared in this scope
src/_nc_transforms.cpp:517: error: expected primary-expression before ')'
token
src/_nc_transforms.cpp:517: error: expected `;' before 'PyArray_FromObject'
src/_nc_transforms.cpp: In member function 'Py::Object
Bbox::update_numerix(const Py::Tuple&)':
src/_nc_transforms.cpp:586: error: 'PyArrayObject' was not declared in this
scope

[snip]

src/_nc_transforms.cpp:1275: error: 'retmask' was not declared in this scope
src/_nc_transforms.cpp:1278: error: expected primary-expression before ')'
token
src/_nc_transforms.cpp:1278: error: expected `;' before 'PyArray_FromDims'
src/_nc_transforms.cpp: In function 'void init_nc_transforms()':
src/_nc_transforms.cpp:2428: error: 'import_array' was not declared in this
scope
error: command 'gcc' failed with exit status 1
[EMAIL PROTECTED] matplotlib-0.90.1]#


It seems to trip up when expecting a file 'arrayobject.h' in the /Numeric
directory; indeed that file is not there, though Numeric is on the path.
Numeric came as part of the Mandriva install.

I'd be grateful for any help with this, thanks in advance, Evan
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar, setting limits

2007-03-27 Thread Evan Mason

Thanks, Eric,

Yes, that works for the stripped down version, but not for what I am trying
to do.  The examples I have given have the range of one of the plots nicely
fitting inside that of the other (ie, plot 1 range 15 to 26, plot 2 range 17
to 23), but sometimes with what I am doing I have, for example,  plot 1
range 15 to 23 and plot 2 range 17 to 25.  In this case, passing the levels
from plot 1 to plot 2 means that levels 24 and 25 of plot 2 are stripped
away; this, at least, is what I think is happening because I have white
areas of my plot that weren't there before.  It seems to me that it would be
quite useful to have the option to override the colorbar range, setting it
to be the same as defined by clim, or some other values.

As a solution for now, I think I will just use one colorbar for the two
plots.  Thanks for your help with this, and the tip about being explicit in
my programs!

-Evan




On 3/27/07, Eric Firing <[EMAIL PROTECTED]> wrote:


Evan,

OK, I see what the problem is: you need to tell the second contour
command to use the same contour levels as the first one is using.
Something like this:

figure(1)
CS1 = contourf(x)
clim(cmin, cmax)
colorbar()
figure(2)
CS2 = contourf(y, levels=CS1.levels)
clim(cmin, cmax)
colorbar()

Does this give the desired result?

The big difference between pcolor and contourf in this context is that
pcolor is automatically generating a colormap with 256 colors, and may
use any or all of those colors, so the colorbar is effectively
continuous.  Contourf works with a small discrete set of colors taken
from such a colormap, so colorbar shows the same discrete set.  The
boundaries are either generated automatically in contourf, or set via
the levels kwarg.  Colorbar gets the boundaries from the output of the
contourf call, which pylab saves and passes along to colorbar even if
you don't do so explicitly yourself.  But pylab has no way of knowing
that you want the contour levels in the second figure to match the
first, so you have to be explicit.

Usually at this point someone chimes in to point out the virtues of
being explicit in your program even when you don't have to...

Eric



Evan Mason wrote:
> Hi Eric, the following lines below will show this.  Interestingly, the
> correct (or, at least, what I want) behaviour results from using pcolor,
> but not with contourf.
>
>
> a = arange(12, 27, .5)
> b = arange(17, 23, .5)
> x, y = meshgrid(a, b)
>
> # get max and min for clim
> cmin = min(x.min(), y.min()) # cmin = 12
> cmax = max(x.max(), y.max()) # cmax = 26.5
>
> figure(1)
> contourf(x)
> #pcolor(x)
> clim([cmin, cmax])
> colorbar()
> figure(2)
> contourf(y)
> #pcolor(y)
> clim([cmin, cmax])
> colorbar()
>
>
> -Evan
>
>
>
>
> On 3/27/07, *Eric Firing* < [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> Evan,
>
> That is getting clearer, but it still seems to me that no override
> should be needed in this case; it should "just work", so if it
doesn't,
> either there is a bug in mpl or a bug in the code.  It would be most
> helpful if you would write a stripped-down simplest-possible script
> that
> illustrates the problem.  Then I can either show how to fix the
script,
> or I can use the script to help me track down the mpl bug, if that
is
> the problem.
>
> Eric
>
> Evan Mason wrote:
>  > Hi Eric
>  >
>  > I am using matplotlib-0.90.0.
>  >
>  > I am making 2 contourf subplots of temperature values which have
> similar
>  > but not equal ranges.  In subplot1 the range is 15-25; in
> subplot2 it is
>  > 16 to 24.  I use clim, giving it the max and min values obtained
> from a
>  > comparison of subplot1 and 2; i.e., I use clim([15, 25]) on both
>  > subplots.  The two subplots display exactly as I want them to.
>  >
>  > Next, I want 2 colorbars to go with the two subplots.  I want the
> range
>  > of each colorbar to be the same, set as the clim values (15 and
25).
>  > This happens for subplot1, but not for subplot2, which shows the
> range
>  > 16-24, following its input data range and not the clim values.
>  >
>  > So what I want to know is if it is possible to overide the
colorbar
>  > limits, setting them to 15-25?
>  >
>  > I hope that's clearer now, thanks, Evan
>  >
>  >
>  >
>  > On 3/27/07, * Eric Firing* < [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
>  > <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>> wrote:
>  >
>  > Evan,
>  >
>  > It is 

Re: [Matplotlib-users] colorbar, setting limits

2007-03-27 Thread Evan Mason

Hi Eric, the following lines below will show this.  Interestingly, the
correct (or, at least, what I want) behaviour results from using pcolor, but
not with contourf.


a = arange(12, 27, .5)
b = arange(17, 23, .5)
x, y = meshgrid(a, b)

# get max and min for clim
cmin = min(x.min(), y.min()) # cmin = 12
cmax = max(x.max(), y.max()) # cmax = 26.5

figure(1)
contourf(x)
#pcolor(x)
clim([cmin, cmax])
colorbar()
figure(2)
contourf(y)
#pcolor(y)
clim([cmin, cmax])
colorbar()


-Evan




On 3/27/07, Eric Firing <[EMAIL PROTECTED]> wrote:


Evan,

That is getting clearer, but it still seems to me that no override
should be needed in this case; it should "just work", so if it doesn't,
either there is a bug in mpl or a bug in the code.  It would be most
helpful if you would write a stripped-down simplest-possible script that
illustrates the problem.  Then I can either show how to fix the script,
or I can use the script to help me track down the mpl bug, if that is
the problem.

Eric

Evan Mason wrote:
> Hi Eric
>
> I am using matplotlib-0.90.0.
>
> I am making 2 contourf subplots of temperature values which have similar
> but not equal ranges.  In subplot1 the range is 15-25; in subplot2 it is
> 16 to 24.  I use clim, giving it the max and min values obtained from a
> comparison of subplot1 and 2; i.e., I use clim([15, 25]) on both
> subplots.  The two subplots display exactly as I want them to.
>
> Next, I want 2 colorbars to go with the two subplots.  I want the range
> of each colorbar to be the same, set as the clim values (15 and 25).
> This happens for subplot1, but not for subplot2, which shows the range
> 16-24, following its input data range and not the clim values.
>
> So what I want to know is if it is possible to overide the colorbar
> limits, setting them to 15-25?
>
> I hope that's clearer now, thanks, Evan
>
>
>
> On 3/27/07, * Eric Firing* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> Evan,
>
> It is still not quite clear to me what you want versus what you are
> getting.  With recent versions of mpl, the colorbar automatically
uses
> the same color boundaries as contourf, if that is what the colorbar
is
> tracking.  What version of mpl are you using?
>
> (With the most recent mpl I see that there is a strange bug such
that
> setting clim clobbers the axis tick labeling for the colorbar--yet
> another thing that needs to be figured out and fixed.)
>
>


-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar, setting limits

2007-03-27 Thread Evan Mason

Hi Eric

I am using matplotlib-0.90.0.

I am making 2 contourf subplots of temperature values which have similar but
not equal ranges.  In subplot1 the range is 15-25; in subplot2 it is 16 to
24.  I use clim, giving it the max and min values obtained from a comparison
of subplot1 and 2; i.e., I use clim([15, 25]) on both subplots.  The two
subplots display exactly as I want them to.

Next, I want 2 colorbars to go with the two subplots.  I want the range of
each colorbar to be the same, set as the clim values (15 and 25).  This
happens for subplot1, but not for subplot2, which shows the range 16-24,
following its input data range and not the clim values.

So what I want to know is if it is possible to overide the colorbar limits,
setting them to 15-25?

I hope that's clearer now, thanks, Evan



On 3/27/07, Eric Firing <[EMAIL PROTECTED]> wrote:


Evan,

It is still not quite clear to me what you want versus what you are
getting.  With recent versions of mpl, the colorbar automatically uses
the same color boundaries as contourf, if that is what the colorbar is
tracking.  What version of mpl are you using?

(With the most recent mpl I see that there is a strange bug such that
setting clim clobbers the axis tick labeling for the colorbar--yet
another thing that needs to be figured out and fixed.)

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] colorbar, setting limits

2007-03-27 Thread Evan Mason

Sorry, I realise that my example in my original post doesn't quite make
sense.  My data range is 17 to 23.  I set clim to be clim([15, 25]).  I then
want the colorbar limits to be the same as clim, 15 to 25.  The questions
remains the same, which is how to set the range for colorbar.

Thanks, Evan
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] colorbar, setting limits

2007-03-27 Thread Evan Mason

Hi
I want to set the limits of my colorbar to something different from that of
my plot.  For example I have a contourf plot where I set the colour limits
to be, say:

clim([15,  25])

But I want the limits of the colorbar to be 10 and 30.  I suspect this is
something to do with mappable and vmin and vmax, but I don't see anything
specific about how to do this, either on this forum or on mpl/sourceforge.

Thanks for any help, Evan
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] second x axis

2007-02-15 Thread Evan Mason
> How do I make a second x-axis?  I am looking for something like "twinx" (a
"twiny" would be perfect...)Thanks, Evan
> 
> -
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> 
> ___
> Matplotlib-users mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 

I just noticed this was posted on the 13 Feb; funny it doesn't show up in a
search for 'twiny'.  The answer is there anyway.

-Evan



-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] second x axis

2007-02-15 Thread Evan Mason

How do I make a second x-axis?  I am looking for something like "twinx" (a
"twiny" would be perfect...)

Thanks, Evan
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] contour and basemap

2006-12-31 Thread Evan Mason

In the mpl basemap 'test.py' script, I want to add some contours to the
mercator projection map (test #3).  Just below line 83 (ie, below the 'im  =
imshow..' command I added the line:

m.contour(topodat,[-1000, -2000])

This returns:

/home/evan/downloads/basemap-0.9.4/examples/test.py
82 # plot image over map.
83 im = m.imshow(topodat,cm.jet)
---> 84 m.contour(topodat,[-1000, -2000])
85 m.drawcoastlines()
86 m.drawcountries()

TypeError: contour() takes at least 4 arguments (3 given)
WARNING: Failure executing file: 

I understand the error to mean that I haven't supplied x and y values;
however at this point, if I close all the open figures and enter the line
'contour(topodat,[-1000, -2000])' at the ipython command, it gives me the
plot I want.

I've then tried to use meshgrid to make x and y values (see code below);
this is error free but the contours don't appear.  Again, using contour in
the command line I get the plot I want.  Is it not possible to plot on top
of imshow?

Any help appreciated.


Thanks, Evan




from matplotlib.toolkits.basemap import Basemap, shiftgrid
from scipy import interpolate as Pinterp
from pylab import *
import matplotlib.colors as colors

def doSpline(yVec, newLatRange):
   latRange= range(len(yVec))
   newLatRange = linspace(latRange[0], latRange[-1], newLatRange)
   tck = Pinterp.splrep(latRange, yVec)
   yVec= Pinterp.splev(newLatRange, tck)
   return yVec

topodatin = load('etopo20data.gz')
lonsin = load('etopo20lons.gz')
latsin = load('etopo20lats.gz')
# shift data so lons go from -180 to 180 instead of 20 to 380.
topoin,lons = shiftgrid(180.,topodatin,lonsin,start=False)
lats = latsin
# transform to nx x ny regularly spaced native projection grid
nx = len(lons)
ny = int(80.*len(lats)/90.)
lats_ny = doSpline(lats, ny)

lons_mesh, lats_mesh = meshgrid(lons, lats_ny)

# setup mercator map projection (-80 to +80).
m = Basemap(llcrnrlon=-180.,llcrnrlat=-80,urcrnrlon=180.,urcrnrlat=80.,\
   resolution='c',area_thresh=1.,projection='merc',\
   lon_0=0.5*(lons[0]+lons[-1]),lat_ts=20.)

topodat = m.transform_scalar(topoin,lons,lats,nx,ny)

# setup figure with same aspect ratio as map.
fig=figure()
fig.add_axes([0.1,0.1,0.75,0.75])
# plot image over map.
im = m.imshow(topodat,cm.jet)
# PLOT CONTOURS
m.contour(lons_mesh, lats_mesh, topodat,[-1000, -2000, -3000])
show()
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users