[Matplotlib-users] making multi panel figures

2012-01-12 Thread Michael Rawlins


I have about 140 lines of code that makes a map. I'd like to turn it into a 
program which makes a multiple panel (map) figure. I understand that subplot 
will help to do this. Ideally I would like the 140 lines to be like a 
subroutine called in a loop. In the current code there are two variable which 
would be passed to the subroutine, thetitle and ncfile. These are only two 
things different for each panel. So something like:

do irow = 1, 3
   do icolumn = 1, 3

  call mapping code (thetitle,ncfile)


    enddo
enddo

Here is the code. If the above method is not possible, I assume I'll need to 
repeat the 140 lines N times, where N is the number of panels. 


TIA
Mike



verbose=0 #verbose=2 says a bit more

import sys,getopt

from mpl_toolkits.basemap import Basemap, shiftgrid, cm 
#from netCDF3 import Dataset as NetCDFFile 
from mpl_toolkits.basemap import  NetCDFFile
from pylab import *
#from matplotlib.mlab import csv2rec

alloptions, otherargs= getopt.getopt(sys.argv[1:],'ro:p:X:Y:v:t:l:u:n:') # note 
the : after o and p
proj='lam'
#plotfile=None
#plotfile='testmap2.png'
usejetrev=False
colorbounds=[None,None]
extratext=""
xvar=None
yvar=None
thevar=None


#  Here set map title and the file containing gridded data to plot
thetitle='Map Title'
ncfile = NetCDFFile('simple_xy.nc', 'r')   # Here's filename


therec=None
thelev=None
cbot=None
ctop=None
startlon=-180 #default assumption for starting longitude
for theopt,thearg in alloptions:
    print theopt,thearg
    if theopt=='-o': # -o needs filename after it, which is now thearg
        plotfile=thearg    
    elif theopt=='-p': 
        proj=thearg
    elif theopt=='-X': 
        xvar=thearg
    elif theopt=='-Y': 
        yvar=thearg
    elif theopt=='-v': 
        thevar=thearg
    elif theopt=='-t': 
        thetitle=thearg
    elif theopt=='-l': 
        cbot=thearg
    elif theopt=='-u': 
        ctop=thearg
    elif theopt=='-n': 
        therec=thearg
    elif theopt=='-m': 
        thelev=thearg
    elif theopt=='-r': 
        usejetrev=True
    else: #something went wrong
        print "hmm, what are these??? ", theopt, thearg
        sys.exit()

print "\nPlotting, please wait...maybe more than 10 seconds"
if proj=='lam': #Lambert Conformal
    m = Basemap(llcrnrlon=-80.6,llcrnrlat=38.4,urcrnrlon=-66.0,urcrnrlat=47.7,\
    resolution='l',area_thresh=1000.,projection='lcc',\
    lat_1=65.,lon_0=-73.3)
    xtxt=20. #offset for text
    ytxt=20.
    parallels = arange(38.,48.,2.)
    meridians = arange(-80.,-64.,2.)
else: #cylindrical is default
#    m = Basemap(llcrnrlon=-180.,llcrnrlat=-90,urcrnrlon=180.,urcrnrlat=90.,\
#    resolution='c',area_thresh=1.,projection='cyl')
    m = 
Basemap(llcrnrlon=startlon,llcrnrlat=-90,urcrnrlon=startlon+360.,urcrnrlat=90.,\
    resolution='c',area_thresh=1.,projection='cyl')
    xtxt=1.
    ytxt=0.
    parallels = arange(-90.,90.,30.)
    if startlon==-180:
        meridians = arange(-180.,180.,60.)
    else:
        meridians = arange(0.,360.,60.)

if verbose>1: print m.__doc__ 
xsize = rcParams['figure.figsize'][0]
fig=figure(figsize=(xsize,m.aspect*xsize))
#ax = fig.add_axes([0.08,0.1,0.7,0.7],axisbg='white')
ax = fig.add_axes([0.07,0.00,0.86,1.0],axisbg='white')
# make a pcolor plot.
#x, y = m(lons, lats)
#p = m.pcolor(x,y,maskdat,shading='flat',cmap=cmap)
#clim(*colorbounds)

# axes units units are left, bottom, width, height
#cax = axes([0.85, 0.1, 0.05, 0.7])  #  colorbar axes for map w/ no graticule
#cax = axes([0.88, 0.1, 0.06, 0.81])  #  colorbar axes for map w/ graticule

axes(ax)  # make the original axes current again

#    Plot symbol at station locations    #

# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawcountries()
m.drawstates()
# draw parallels and meridians.
# label on left, right and bottom of map.
#m.drawparallels(parallels,labels=[1,0,0,0])
#m.drawmeridians(meridians,labels=[1,1,0,1])

if not thetitle:
    title(thevar+extratext)
else:
    title(thetitle)

#data = csv2rec('latlon_GHCN.txt',delimiter=' ',names=['lat','lon'])
#for i in range(len(data)):
#    x,y=m(data['lon'][i],data['lat'][i]) # Translate to basemap (Lambert) 
coordinate space
##    ax.text(x,y,'.')
#    plot(x,y,color='black',marker='.',markersize=6.0)

xpt,ypt = m(-75.0,43.0)
ax.text(xpt,ypt,'*')

    
#if plotfile:
#    savefig(plotfile, dpi=72, facecolor='w', bbox_inches='tight', 
edgecolor='w', orientation='portrait')
#else:
#    show()

#plt.savefig('map.png')
plt.savefig('map.eps')
show()
#  comment show to mass produce--
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sou

Re: [Matplotlib-users] making multi panel figures

2012-01-12 Thread Michael Rawlins

On 01/12/12 Ben Root wrote: 

Just a quick suggestion for cleaning up your code, please look into the 
argparse module to make command-line parsing so much easier to use.

http://docs.python.org/dev/library/argparse.html


Ben Root



Command line parsing?  I'm new to python and matplotlib and was given this code 
by a colleague. I've managed to make simple modifications. Don't know enough 
yet to use the examples in the link you provide. 

I've simplified my code as much as possible.  The first 50 lines make a map. 
The code below that makes a 4 panel graphic.  Seems that plt.figure invokes a 
new plot window. But plt.semilogy, plt.loglog, and plt.hist do not, keeping the 
panels in a single window. This is what I need. Trying now to figure out how to 
transfer the fig=plt.figure line into the subplot section, without popping up a 
new window.

Mike


verbose=0 #verbose=2 says a bit more

import sys,getopt

from mpl_toolkits.basemap import Basemap, shiftgrid, cm 
#from netCDF3 import Dataset as NetCDFFile 
from mpl_toolkits.basemap import  NetCDFFile
from pylab import *
import matplotlib.pyplot as plt

#fg = plt.figure(figsize=(10,8))
#adj = plt.subplots_adjust(hspace=0.4,wspace=0.4)
#sp = plt.subplot(2,2,1)

#  Here set map title and the file containing gridded data to plot
thetitle='Map #1'
ncfile = NetCDFFile('simple_xy.nc', 'r')   # Here's filename

startlon=-180 #default assumption for starting longitude

m = Basemap(llcrnrlon=-80.6,llcrnrlat=38.4,urcrnrlon=-66.0,urcrnrlat=47.7,\
    resolution='l',area_thresh=1000.,projection='lcc',\
    lat_1=65.,lon_0=-73.3)
xtxt=20. #offset for text
ytxt=20.
parallels = arange(38.,48.,2.)
meridians = arange(-80.,-64.,2.)

if verbose>1: print m.__doc__ 
xsize = rcParams['figure.figsize'][0]
fig=plt.figure(figsize=(xsize,m.aspect*xsize))
ax = fig.add_axes([0.07,0.00,0.86,1.0],axisbg='white')
axes(ax)  # make the original axes current again

# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawcountries()
m.drawstates()

if not thetitle:
    title(thevar+extratext)
else:
    title(thetitle)

#plt.show()

##
# Example: http://physics.nmt.edu/~raymond/software/python_notes/paper004.html
sp = plt.subplot(2,2,1)
x = linspace(0,10,101)
y = exp(x)
l1 = plt.semilogy(x,y,color='m',linewidth=2)

sp = plt.subplot(2,2,2)
y = x**-1.67
l1 = plt.loglog(x,y)

sp = plt.subplot(2,2,3)
x = arange(1001)
y = mod(x,2.87)
l1 = plt.hist(y,color='r',rwidth = 0.8)

sp = plt.subplot(2,2,4)
l1 = plt.hist(y,bins=25,normed=True,cumulative=True,orientation='horizontal')

plt.show()
#plt.savefig('map.eps')




Just a quick suggestion for cleaning up your code, please look into the 
argparse module to make command-line parsing so much easier to use.--
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] making multi panel figures

2012-01-12 Thread Michael Rawlins


On 01/12/12 Ben Root wrote: 

On Thu, Jan 12, 2012 at 2:20 PM, Michael Rawlins  wrote:


>On 01/12/12 Ben Root wrote: 
>
>Just a quick suggestion for cleaning up your code, please look into the 
argparse module to make command-line parsing so much easier to use.
>
>http://docs.python.org/dev/library/argparse.html
>
>
>Ben Root
>
>
>
>Command line parsing?  I'm new to python and matplotlib and was given this 
>code by a colleague. I've managed to make simple modifications. Don't know 
>enough yet to use the examples in the link you provide. 
>
>I've simplified my code as much as possible.  The first 50 lines make a map. 
>The code below that makes a 4 panel graphic.  Seems that plt.figure invokes a 
>new plot window. But plt.semilogy, plt.loglog, and plt.hist do not, keeping 
>the panels in a single window. This is what I need. Trying now to figure out 
>how to transfer the fig=plt.figure line into the subplot section, without 
>popping up a new window.
>
>Mike
>
>
>

Ok, a quick crash course:

A "figure" can hold one or more "axes" (or subplots).  When using "plt", you 
can choose to make figures explicitly with the "fig = plt.figure()" command or 
not.  The same is true for axes objects.  If you call a command that needs a 
figure and/or an axes object to have been made and they don't exist, then they 
are made for you automatically. Otherwise, the most recently accessed 
figure/axes are assumed.  This is why plt.hist(), plt.semilog() and others are 
not creating a new figure window if one already existed.

Anyway, for your code, you do not want to bring in the plt.figure() call into 
the subploting section.  The example you were given takes advantage of pyplot's 
implicit syntax (where it is implicitly assumed which axes/figure object you 
are using). However, I personally do not like that approach, and instead 
decided to show you an explicit style.  I created a foobar() function that 
takes a blank figure object and other parameters, creates the four subplot axes 
and performs drawing on each of them.  Note that the title is for the subplot, 
not for the figure.  If you want a title for the figure above all the other 
subplots, use "fig.suptitle()".  I then have a loop where a figure is created 
each time, the foobar() function acts on that figure, saved and then cleared 
before the next iteration.

Note, I noticed you had "plt.show()" commented out before the call to 
"plt.savefig()".  Usually, you will want savefig() to come *before* show() 
because closing the figure window will destroy the figure object, resulting in 
a blank figure to save if done afterwards.

I hope this is helpful!
Ben Root




OK starting to make sense. Yes very helpful.  I think what's you've set up 
might work, provided I can pass a filename for data into the function.

At the moment I'm getting an error:

NameError: name 'foobar' is not defined

for the line with:  foobar(fig, m, title)

Mike--
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] making multi panel figures

2012-01-12 Thread Michael Rawlins
On 01/12/12 Ben Root wrote: 


On Thu, Jan 12, 2012 at 4:00 PM, Michael Rawlins  wrote:


>
>On 01/12/12 Ben Root wrote: 
>
>On Thu, Jan 12, 2012 at 2:20 PM, Michael Rawlins  wrote:
>
>
>>On 01/12/12 Ben Root wrote: 
>>
>>Just a quick suggestion for cleaning up your code, please look into the 
argparse module to make command-line parsing so much easier to use.
>>
>>http://docs.python.org/dev/library/argparse.html
>>
>>
>>Ben Root
>>
>>
>>
>>Command line parsing?  I'm new to python and matplotlib and was given this 
>>code by a colleague. I've managed to make simple modifications. Don't know 
>>enough yet to use the examples in the link you provide. 
>>
>>I've simplified my code as much as possible.  The first 50 lines make a map. 
>>The code below that makes a 4 panel graphic.  Seems that plt.figure invokes a 
>>new plot window. But plt.semilogy, plt.loglog, and plt.hist do not, keeping 
>>the panels in a single window. This is what I need. Trying now to figure out 
>>how to transfer the fig=plt.figure line into the subplot section, without 
>>popping up a new window.
>>
>>Mike
>>
>>
>>
>
>Ok, a quick crash course:
>
>A "figure" can hold one or more "axes" (or subplots).  When using "plt", you 
>can choose to make figures explicitly with the "fig = plt.figure()" command or 
>not.  The same is true for axes objects.  If you call a command that needs a 
>figure and/or an axes object to have been made and they don't exist, then they 
>are made for you automatically. Otherwise, the most recently accessed 
>figure/axes are assumed.  This is why plt.hist(), plt.semilog() and others are 
>not creating a new figure window if one already existed.
>
>Anyway, for your code, you do not want to bring in the plt.figure() call into 
>the subploting section.  The example you were given takes advantage of 
>pyplot's implicit syntax (where it is implicitly assumed which axes/figure 
>object you are using). However, I personally do not like that approach, and 
>instead decided to show you an explicit style.  I created a foobar() function 
>that takes a blank figure object and other parameters, creates the four 
>subplot axes and performs drawing on each of them.  Note that the title is for 
>the subplot, not for the figure.  If you want a title for the figure above all 
>the other subplots, use "fig.suptitle()".  I then have a loop where a figure 
>is created each time, the foobar() function acts on that figure, saved and 
>then cleared before the next iteration.
>
>Note, I noticed you had "plt.show()" commented out before the call to 
>"plt.savefig()".  Usually, you will want savefig() to come *before* show() 
>because closing the figure window will destroy the figure object, resulting in 
>a blank figure to save if done afterwards.
>
>I hope this is helpful!
>Ben Root
>
>
>
>
>OK starting to make sense. Yes very helpful.  I think what's you've set up 
>might work, provided I can pass a filename for data into the function.
>
>At the moment I'm getting an error:
>
>NameError: name 'foobar' is not defined
>
>for the line with:  foobar(fig, m, title)
>
>Mike
>
>

My bad... I put the declaration of the foobar() function after it is called in 
the script.  This isn't an issue if they are in separate scopes, but because 
"def foobar" is in the same scope as the call to it, it must have already been 
declared before it gets called. Just move that function to the area after all 
the imports.

Ben Root


Thanks for the help.  Code throwing another error:

Traceback (most recent call last):
  File "panels_testingNEW4.py", line 69, in 
    foobar(fig, m, title)
  File "panels_testingNEW4.py", line 23, in foobar
    title(title)
TypeError: 'str' object is not callable--
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] placing colorbar when using subplot command

2012-01-17 Thread Michael Rawlins


I'm relatively new to matplotlib. Trying to place a colorbar in a figure. The 
code below, placed in a file and executed with python, draws 4 maps using 
basemap. I've been unable to get a colorbar to show up anywhere on the figure. 
Ideally I would like the option of placing a colorbar across the bottom, 
spanning across both bottom map panels.  Also would need the option of placing 
a colorbar either to the right of or below each map. Uncommenting the two lines 
under "Here make a colorbar" cause an error. I've used those commands when 
creating just one map using the figure command.

TIA,
Mike



verbose=0 #verbose=2 says a bit more
import sys,getopt
from mpl_toolkits.basemap import Basemap, shiftgrid, cm 
#from netCDF3 import Dataset as NetCDFFile 
from mpl_toolkits.basemap import  NetCDFFile
from pylab import *

alloptions, otherargs= getopt.getopt(sys.argv[1:],'ro:p:X:Y:v:t:l:u:n:') # note 
the : after o and p
proj='lam'

cmap = cm.get_cmap('jet', 10)    # 10 discrete colors

print "\nPlotting, please wait...maybe more than 10 seconds"
if proj=='lam': #Lambert Conformal
    m = Basemap(llcrnrlon=-80.6,llcrnrlat=38.4,urcrnrlon=-66.0,urcrnrlat=47.7,\
    resolution='l',area_thresh=1000.,projection='lcc',\
    lat_1=65.,lon_0=-73.3)
xtxt=20. #offset for text
ytxt=20.
parallels = arange(38.,48.,2.)
meridians = arange(-80.,-64.,2.)

xsize = rcParams['figure.figsize'][0]
fig=figure(figsize=(xsize,m.aspect*xsize))
cax = axes([0.88, 0.1, 0.06, 0.81])  #  colorbar axes for map w/ graticule


subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0.15, 
hspace=0.11)
# Make the first map at upper left
sp = plt.subplot(2,2,1)

#  Here make a colorbar.
#cax = axes([0.88, 0.1, 0.06, 0.81])  #  colorbar axes for map w/ graticule
#colorbar(format='%3.1f', ticks=[-1.5, -1.2, -0.9, -0.6, -0.3, 0.0, 0.3, 0.6, 
0.9, 1.2, 1.5], cax=cax)

# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawcountries()
m.drawstates()

#  Make the second map  
#
sp = plt.subplot(2,2,2)
# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawcountries()
m.drawstates()

#  Make the third map   
#
sp = plt.subplot(2,2,3)
# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawcountries()
m.drawstates()

#  Make the fourth map   
#
sp = plt.subplot(2,2,4)
# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawcountries()
m.drawstates()

plt.show()
plt.savefig("map.eps")
plt.clf()   # Clears the figure object--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] placing colorbar when using subplot command

2012-01-17 Thread Michael Rawlins





 From: Benjamin Root 
To: Michael Rawlins  
Cc: "matplotlib-users@lists.sourceforge.net" 
 
Sent: Tuesday, January 17, 2012 10:36 AM
Subject: Re: [Matplotlib-users] placing colorbar when using subplot command
 



On Tue, Jan 17, 2012 at 9:30 AM, Michael Rawlins  wrote:


>
>I'm relatively new to matplotlib. Trying to place a colorbar in a figure. The 
>code below, placed in a file and executed with python, draws 4 maps using 
>basemap. I've been unable to get a colorbar to show up anywhere on the figure. 
>Ideally I would like the option of placing a colorbar across the bottom, 
>spanning across both bottom map panels.  Also would need the option of placing 
>a colorbar either to the right of or below each map. Uncommenting the two 
>lines under "Here make a colorbar" cause an error. I've used those commands 
>when creating just one map using the figure command.
>
>
>TIA,
>Mike
>
>
>
>

Mike,

Try using the axes_grid1 toolkit to produce your axes objects and to allocate 
enough room for colorbars.

http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/index.html

Cheers!
Ben Root

P.S. - a little history, there used to be an axes_grid toolkit, but has since 
been superseded by axes_grid1.


Clicking on source code on that page produces an error. For several of the 
graphic on that page, dropping the code into a file and running also produces 
various errors. Being new to this software, having a specific example that I 
can run and then incorporate into my code would be a big help. 

Mike--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] placing colorbar when using subplot command

2012-01-17 Thread Michael Rawlins





 From: Benjamin Root 
To: Michael Rawlins  
Cc: "matplotlib-users@lists.sourceforge.net" 
 
Sent: Tuesday, January 17, 2012 2:02 PM
Subject: Re: [Matplotlib-users] placing colorbar when using subplot command
 



On Tue, Jan 17, 2012 at 12:37 PM, Michael Rawlins  wrote:


>
>
>
>
>
> From: Benjamin Root 
>To: Michael Rawlins  
>Cc: "matplotlib-users@lists.sourceforge.net" 
> 
>Sent: Tuesday, January 17, 2012 10:36 AM
>Subject: Re: [Matplotlib-users] placing colorbar when using subplot command
> 
>
>
>
>On Tue, Jan 17, 2012 at 9:30 AM, Michael Rawlins  wrote:
>
>
>>
>>I'm relatively new to matplotlib. Trying to place a colorbar in a figure. The 
>>code below, placed in a file and executed with python, draws 4 maps using 
>>basemap. I've been unable to get a colorbar to show up anywhere on the 
>>figure. Ideally I would like the option of placing a colorbar across the 
>>bottom, spanning across both bottom map panels.  Also would need the option 
>>of placing a colorbar either to the right of or below each map. Uncommenting 
>>the two lines under "Here make a colorbar" cause an error. I've used those 
>>commands when creating just one map using the figure command.
>>
>>
>>TIA,
>>Mike
>>
>>
>>
>>
>
>Mike,
>
>Try using the axes_grid1 toolkit to produce your axes objects and to allocate 
>enough room for colorbars.
>
>http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/index.html
>
>Cheers!
>Ben Root
>
>P.S. - a little history, there used to be an axes_grid toolkit, but has since 
>been superseded by axes_grid1.
>
>
>Clicking on source code on that page produces an error. For several of the 
>graphic on that page, dropping the code into a file and running also produces 
>various errors. Being new to this software, having a specific example that I 
>can run and then incorporate into my code would be a big help. 
>
>Mike
>
>
>

Mike,

I do apologize for that.  We will have to get that fixed on the website (not 
sure why it is happening).  I have attached an example file for you to try.  
Also, which version of matplotlib are you running?  Without the error message 
you are getting, it would be hard to tell you what is wrong (most likely it is 
a version issue).

Ben Root


Ben et al.

This line causes the error:

from mpl_toolkits.axes_grid1 import AxesGrid

Traceback (most recent call last):
  File "demo_axes_grid.py", line 2, in 
    from mpl_toolkits.axes_grid1 import AxesGrid
  File 
"/usr/local/lib/python2.6/dist-packages/mpl_toolkits/axes_grid1/__init__.py", 
line 4, in 
    from axes_grid import Grid, ImageGrid, AxesGrid
  File 
"/usr/local/lib/python2.6/dist-packages/mpl_toolkits/axes_grid1/axes_grid.py", 
line 6, in 
    import colorbar as mcolorbar
  File 
"/usr/local/lib/python2.6/dist-packages/mpl_toolkits/axes_grid1/colorbar.py", 
line 26, in 
    from matplotlib import docstring
ImportError: cannot import name docstring


I see no axes_grid1.py where I guess it belongs. Here's what's in 
/usr/share/pyshared/mpl_toolkits/axes_grid


parasite_axes.py    axislines.py  anchored_artists.py  inset_locator.py
grid_helper_curvelinear.py  axes_size.py  __init__.py
grid_finder.py  axes_rgb.py   axes_divider.py
clip_path.py    axes_grid.py  angle_helper.py


Do I need to upgrade python?  Matplotlib?  Add just a file or two?

Mike--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] placing colorbar when using subplot command

2012-01-18 Thread Michael Rawlins





 From: Benjamin Root 
To: Michael Rawlins  
Cc: "matplotlib-users@lists.sourceforge.net" 
 
Sent: Tuesday, January 17, 2012 2:02 PM
Subject: Re: [Matplotlib-users] placing colorbar when using subplot command
 



On Tue, Jan 17, 2012 at 12:37 PM, Michael Rawlins  wrote:


>
>
>
>
>
> From: Benjamin Root 
>To: Michael Rawlins  
>Cc: "matplotlib-users@lists.sourceforge.net" 
> 
>Sent: Tuesday, January 17, 2012 10:36 AM
>Subject: Re: [Matplotlib-users] placing colorbar when using subplot command
> 
>
>
>
>On Tue, Jan 17, 2012 at 9:30 AM, Michael Rawlins  wrote:
>
>
>>
>>I'm relatively new to matplotlib. Trying to place a colorbar in a figure. The 
>>code below, placed in a file and executed with python, draws 4 maps using 
>>basemap. I've been unable to get a colorbar to show up anywhere on the 
>>figure. Ideally I would like the option of placing a colorbar across the 
>>bottom, spanning across both bottom map panels.  Also would need the option 
>>of placing a colorbar either to the right of or below each map. Uncommenting 
>>the two lines under "Here make a colorbar" cause an error. I've used those 
>>commands when creating just one map using the figure command.
>>
>>
>>TIA,
>>Mike
>>
>>
>>
>>
>
>Mike,
>
>Try using the axes_grid1 toolkit to produce your axes objects and to allocate 
>enough room for colorbars.
>
>http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/index.html
>
>Cheers!
>Ben Root
>
>P.S. - a little history, there used to be an axes_grid toolkit, but has since 
>been superseded by axes_grid1.
>
>
>Clicking on source code on that page produces an error. For several of the 
>graphic on that page, dropping the code into a file and running also produces 
>various errors. Being new to this software, having a specific example that I 
>can run and then incorporate into my code would be a big help. 
>
>Mike
>
>
>

Mike,

I do apologize for that.  We will have to get that fixed on the website (not 
sure why it is happening).  I have attached an example file for you to try.  
Also, which version of matplotlib are you running?  Without the error message 
you are getting, it would be hard to tell you what is wrong (most likely it is 
a version issue).

Ben Root



Version 0.99.1.1 installed through Synaptic package manager on system running 
Ubuntu 10.04. I'd rather not attempt a fresh install from sources just yet.  
Adding a colorbar alonside each map panel is possible. Anyone able to modify 
that code to make that work? I'm assuming it very simple for an experienced 
user.  Also, is it possible to add axes_grid1.py to my directory? If I want to 
get fancy in the future I will install version 1 and use axes_grid1.py.

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__
'0.99.1.1'
>>> --
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] placing colorbar when using subplot command

2012-01-19 Thread Michael Rawlins





 From: Michael Rawlins 
To: Benjamin Root  
Cc: "matplotlib-users@lists.sourceforge.net" 
 
Sent: Wednesday, January 18, 2012 10:13 AM
Subject: Re: [Matplotlib-users] placing colorbar when using subplot command
 






 From: Benjamin Root 
To: Michael Rawlins  
Cc: "matplotlib-users@lists.sourceforge.net" 
 
Sent: Tuesday, January 17, 2012 2:02 PM
Subject: Re: [Matplotlib-users] placing colorbar when using subplot command
 



On Tue, Jan 17, 2012 at 12:37 PM, Michael Rawlins  wrote:


>
>
>
>
>____
> From: Benjamin Root 
>To: Michael Rawlins  
>Cc: "matplotlib-users@lists.sourceforge.net" 
> 
>Sent: Tuesday, January 17, 2012 10:36 AM
>Subject: Re: [Matplotlib-users] placing colorbar when using subplot command
> 
>
>
>
>On Tue, Jan 17, 2012 at 9:30 AM, Michael Rawlins  wrote:
>
>
>>
>>I'm relatively new to matplotlib. Trying to place a colorbar in a figure. The 
>>code below, placed in a file and executed with python, draws 4 maps using 
>>basemap. I've been unable to get a colorbar to show up anywhere on the 
>>figure. Ideally I would like the option of placing a colorbar across the 
>>bottom, spanning across both bottom map panels.  Also would need the option 
>>of placing a colorbar either to the right of or below each map. Uncommenting 
>>the two lines under "Here make a colorbar" cause an error. I've used those 
>>commands when creating just one map using the figure command.
>>
>>
>>TIA,
>>Mike
>>
>>
>>
>>
>
>Mike,
>
>Try using the axes_grid1 toolkit to produce your axes objects and to allocate 
>enough room for colorbars.
>
>http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/index.html
>
>Cheers!
>Ben Root
>
>P.S. - a little history, there used to be an axes_grid toolkit, but has since 
>been superseded by axes_grid1.
>
>
>Clicking on source code on that page produces an error. For several of the 
>graphic on that page, dropping the code into a file and running also produces 
>various errors. Being new to this software, having a specific example that I 
>can run and then incorporate into my code would be a big help. 
>
>Mike
>
>
>

Mike,

I do apologize for that.  We will have to get that fixed on the website (not 
sure why it is happening).  I have attached an example file for you to try.  
Also, which version of matplotlib are you running?  Without the error message 
you are getting, it would be hard to tell you what is wrong (most likely it is 
a version issue).

Ben Root



Version 0.99.1.1 installed through Synaptic package manager on system running 
Ubuntu 10.04. I'd rather not attempt a fresh install from sources just yet.  
Adding a colorbar alonside each map panel is possible. Anyone able to modify 
that code to make that work? I'm assuming it very simple for an experienced 
user.  Also, is it possible to add axes_grid1.py to my directory? If I want to 
get fancy in the future I will install version 1 and use axes_grid1.py. 

Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__
'0.99.1.1'
>>> 




Forum:

Still unable to get a colorbar alongside the panels in this simple example.  
One last request for assistance. Thanks.

Mike

import sys,getopt
from mpl_toolkits.basemap import Basemap, shiftgrid, cm 
#from netCDF3 import Dataset as NetCDFFile 
from mpl_toolkits.basemap import  NetCDFFile
from pylab import *
import  matplotlib.pyplot as plt

cmap = cm.get_cmap('jet', 10)    # 10 discrete colors

m = Basemap(llcrnrlon=-80.6,llcrnrlat=38.4,urcrnrlon=-66.0,urcrnrlat=47.7,\
    resolution='l',area_thresh=1000.,projection='lcc',\
    lat_1=65.,lon_0=-73.3)
xtxt=20. #offset for text
ytxt=20.
parallels = arange(38.,48.,2.)
meridians = arange(-80.,-64.,2.)

xsize = rcParams['figure.figsize'][0]
fig=figure(figsize=(xsize,m.aspect*xsize))


subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0.15, 
hspace=0.11)
# Make the first map
plt.subplot(1,2,1)

# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawcountries()
m.drawstates()

#  Here make a colorbar.
cax = axes([0.88, 0.1, 0.06, 0.81])  #  colorbar axes for map w/ graticule
#colorbar(format='%3.1f', ticks=[-1.5, -1.2, -0.9, -0.6, -0.3, 0.0, 0.3, 0.6, 
0.9, 1.2, 1.5], cax=cax)
#colorbar(cax=cax)

#  Make the second map  
###

Re: [Matplotlib-users] placing colorbar when using subplot command

2012-01-19 Thread Michael Rawlins





 From: Benjamin Root 
To: Michael Rawlins  
Cc: "matplotlib-users@lists.sourceforge.net" 
 
Sent: Thursday, January 19, 2012 10:07 AM
Subject: Re: [Matplotlib-users] placing colorbar when using subplot command
 



On Thursday, January 19, 2012, Michael Rawlins  wrote:
>
>
> ________
> From: Michael Rawlins 
> To: Benjamin Root 
> Cc: "matplotlib-users@lists.sourceforge.net" 
> 
> Sent: Wednesday, January 18, 2012 10:13 AM
> Subject: Re: [Matplotlib-users] placing colorbar when using subplot command
>
>
>
> ____________
> From: Benjamin Root 
> To: Michael Rawlins 
> Cc: "matplotlib-users@lists.sourceforge.net" 
> 
> Sent: Tuesday, January 17, 2012 2:02 PM
> Subject: Re: [Matplotlib-users] placing colorbar when using subplot command
>
>
> On Tue, Jan 17, 2012 at 12:37 PM, Michael Rawlins  wrote:
>
>
> 
> From: Benjamin Root 
> To: Michael Rawlins 
> Cc: "matplotlib-users@lists.sourceforge.net" 
> 
> Sent: Tuesday, January 17, 2012 10:36 AM
> Subject: Re: [Matplotlib-users] placing colorbar when using subplot command
>
>
> On Tue, Jan 17, 2012 at 9:30 AM, Michael Rawlins  wrote:
>
> I'm relatively new to matplotlib. Trying to place a colorbar in a figure. The 
> code below, placed in a file and executed with python, draws 4 maps using 
> basemap. I've been unable to get a colorbar to show up anywhere on the 
> figure. Ideally I would like the option of placing a colorbar across the 
> bottom, spanning across both bottom map panels.  Also would need the option 
> of placing a colorbar either to the right of or below each map. Uncommenting 
> the two lines under "Here make a colorbar" cause an error. I've used those 
> commands when creating just one map using the figure command.
> TIA,
> Mike
>
>
> Mike,
>
> Try using the axes_grid1 toolkit to produce your axes objects and to allocate 
> enough room for colorbars.
>
> http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/index.html
>
> Cheers!
> Ben Root
>
> P.S. - a little history, there used to be an axes_grid toolkit, but has since 
> been superseded by axes_grid1.
>
>
> Clicking on source code on that page produces an error. For several of the 
> graphic on that page, dropping the code into a file and running also produces 
> various errors. Being new to this software, having a specific example that I 
> can run and then incorporate into my code would be a big help.
>
> Mike
>
>
>
> Mike,
>
> I do apologize for that.  We will have to get that fixed on the website (not 
> sure why it is happening).  I have attached an example file for you to try.  
> Also, which version of matplotlib are you running?  Without the error message 
> you are getting, it would be hard to tell you what is wrong (most likely it 
> is a version issue).
>
> Ben Root
>
>
>
> Version 0.99.1.1 installed through Synaptic package manager on system running 
> Ubuntu 10.04. I'd rather not attempt a fresh install from sources just yet.  
> Adding a colorbar alonside each map panel is possible. Anyone able to modify 
> that code to make that work? I'm assuming it very simple for an experienced 
> user.  Also, is it possible to add axes_grid1.py to my directory? If I want 
> to get fancy in the future I will install version 1 and use axes_grid1.py.
>
> Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
> [GCC 4.4.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import matplotlib
>>>> matplotlib.__version__
> '0.99.1.1'
>>>>
>
>
>
>
> Forum:
>
> Still unable to get a colorbar alongside the panels in this simple example.  
> One last request for assistance. Thanks.
>
> Mike
>
> import sys,getopt
> from mpl_toolkits.basemap import Basemap, shiftgrid, cm
> #from netCDF3 import Dataset as NetCDFFile
> from mpl_toolkits.basemap import  NetCDFFile
> from pylab import *
> import  matplotlib.pyplot as plt
>
> cmap = cm.get_cmap('jet', 10)    # 10 discrete colors
>
> m = Basemap(llcrnrlon=-80.6,llcrnrlat=38.4,urcrnrlon=-66.0,urcrnrlat=47.7,\
>     resolution='l',area_thresh=1000.,projection='lcc',\
>     lat_1=65.,lon_0=-73.3)
> xtxt=20. #offset for text
> ytxt=20.
> parallels = arange(38.,48.,2.)
> meridians = arange(-80.,-64.,2.)
>
> xsize = rcParams['figure.figsize'][0]
> fig=figure(figsize=(xsize,m.aspect*xsize))
>
> #

Re: [Matplotlib-users] placing colorbar when using subplot command

2012-01-19 Thread Michael Rawlins





 From: Benjamin Root 
To: Michael Rawlins  
Cc: "matplotlib-users@lists.sourceforge.net" 
 
Sent: Thursday, January 19, 2012 10:07 AM
Subject: Re: [Matplotlib-users] placing colorbar when using subplot command
 

On Thursday, January 19, 2012, Michael Rawlins  wrote:
>
>
>
> Forum:
>
> Still unable to get a colorbar alongside the panels in this simple example.  
> One last request for assistance. Thanks.
>
> Mike
>
> import sys,getopt
> from mpl_toolkits.basemap import Basemap, shiftgrid, cm
> #from netCDF3 import Dataset as NetCDFFile
> from mpl_toolkits.basemap import  NetCDFFile
> from pylab import *
> import  matplotlib.pyplot as plt
>
> cmap = cm.get_cmap('jet', 10)    # 10 discrete colors
>
> m = Basemap(llcrnrlon=-80.6,llcrnrlat=38.4,urcrnrlon=-66.0,urcrnrlat=47.7,\
>     resolution='l',area_thresh=1000.,projection='lcc',\
>     lat_1=65.,lon_0=-73.3)
> xtxt=20. #offset for text
> ytxt=20.
> parallels = arange(38.,48.,2.)
> meridians = arange(-80.,-64.,2.)
>
> xsize = rcParams['figure.figsize'][0]
> fig=figure(figsize=(xsize,m.aspect*xsize))
>
> 
> subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0.15, 
> hspace=0.11)
> # Make the first map
> plt.subplot(1,2,1)
>
> # draw coastlines and political boundaries.
> m.drawcoastlines()
> m.drawcountries()
> m.drawstates()
>
> #  Here make a colorbar.
> cax = axes([0.88, 0.1, 0.06, 0.81])  #  colorbar axes for map w/ graticule
> #colorbar(format='%3.1f', ticks=[-1.5, -1.2, -0.9, -0.6, -0.3, 0.0, 0.3, 0.6, 
> 0.9, 1.2, 1.5], cax=cax)
> #colorbar(cax=cax)
>
> #  Make the second map  
> #
> plt.subplot(1,2,2)
> # draw coastlines and political boundaries.
> m.drawcoastlines()
> m.drawcountries()
> m.drawstates()
>
> plt.show()
> plt.savefig("map.eps")
> plt.clf()   # Clears the figure object
>
> --
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>

I recommend upgrading to v1.1.0. There are some PPAs out there that has a more 
recent version of mpl available as a package. Or you can install from source.  
Instructions for doing that is in the FAQ.

Ben Root


Have upgraded to v1.2.x.  The example above runs fine. Ideally would like to 
place a colorbar to right of each panel or below each panel or one single 
colorbar spanning across both maps.  Pointers to specific examples or edits to 
the code much appreciated. Note: basemap is required to run the example.

Mike--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] installed python-scipy causing errors with numpy

2012-02-18 Thread Michael Rawlins


A couple weeks ago I installed version 1.2 from sources, as described here:

http://matplotlib.sourceforge.net/users/installing.html

I'm running Ubuntu 10.04 LTS.  Everything was working fine.  Looks like numpy 
version 1.3 in place. A few minutes ago I installed python-scipy from the 
Ubuntu Synaptic package manager.  Getting this any time I run a program:

>python colorbar_testing.py
Traceback (most recent call last):
  File "colorbar_testing.py", line 5, in 
    from matplotlib import pyplot, mpl
  File "/usr/local/lib/python2.6/dist-packages/matplotlib/__init__.py", line 
173, in 
    __version__numpy__, numpy.__version__))
ImportError: numpy 1.4 or later is required; you have 1.3.0


Version control with python, matplotlib, numpy, etc problematic when compiled 
from source?  Shall I reinstall everything again, including python-scipy? What 
order?  Thanks.--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] installed python-scipy causing errors with numpy

2012-02-18 Thread Michael Rawlins




 From: Eric Firing 
To: matplotlib-users@lists.sourceforge.net 
Sent: Saturday, February 18, 2012 12:26 PM
Subject: Re: [Matplotlib-users] installed python-scipy causing errors with numpy
 
On 02/18/2012 07:17 AM, Michael Rawlins wrote:
>
> A couple weeks ago I installed version 1.2 from sources, as described here:
>
> http://matplotlib.sourceforge.net/users/installing.html
>
> I'm running Ubuntu 10.04 LTS. Everything was working fine. Looks like
> numpy version 1.3 in place. A few minutes ago I installed python-scipy
> from the Ubuntu Synaptic package manager. Getting this any time I run a
> program:
>
>  >python colorbar_testing.py
> Traceback (most recent call last):
> File "colorbar_testing.py", line 5, in 
> from matplotlib import pyplot, mpl
> File "/usr/local/lib/python2.6/dist-packages/matplotlib/__init__.py",
> line 173, in 
> __version__numpy__, numpy.__version__))
> ImportError: numpy 1.4 or later is required; you have
 1.3.0
>
>
> Version control with python, matplotlib, numpy, etc problematic when
> compiled from source? Shall I reinstall everything again, including
> python-scipy? What order? Thanks.

You need to remove your numpy and scipy packages and install both of 
these from source (just use the most recent releases), and then rebuild 
matplotlib.  Numpy has to be installed before building either scipy or 
mpl, but mpl and scipy are independent of each other so either can be 
built once a suitable numpy is there.

Eric


I did not mention that I already had python 2.6 installed when I --
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] installed python-scipy causing errors with numpy

2012-02-18 Thread Michael Rawlins





 From: Eric Firing 
To: matplotlib-users@lists.sourceforge.net 
Sent: Saturday, February 18, 2012 12:26 PM
Subject: Re: [Matplotlib-users] installed python-scipy causing errors with numpy
 
On 02/18/2012 07:17 AM, Michael Rawlins wrote:
>
> A couple weeks ago I installed version 1.2 from sources, as described here:
>
> http://matplotlib.sourceforge.net/users/installing.html
>
> I'm running Ubuntu 10.04 LTS. Everything was working fine. Looks like
> numpy version 1.3 in place. A few minutes ago I installed python-scipy
> from the Ubuntu Synaptic package manager. Getting this any time I run a
> program:
>
>  >python colorbar_testing.py
> Traceback (most recent call last):
> File "colorbar_testing.py", line 5, in 
> from matplotlib import pyplot, mpl
> File "/usr/local/lib/python2.6/dist-packages/matplotlib/__init__.py",
> line 173, in 
> __version__numpy__, numpy.__version__))
> ImportError: numpy 1.4 or later is required; you have 1.3.0
>
>
> Version control with python, matplotlib, numpy, etc problematic when
> compiled from source? Shall I reinstall everything again, including
> python-scipy? What order? Thanks.

You need to remove your numpy and scipy packages and install both of 
these from source (just use the most recent releases), and then rebuild 
matplotlib.  Numpy has to be installed before building either scipy or 
mpl, but mpl and scipy are independent of each other so either can be 
built once a suitable numpy is there.

Eric



Thanks Eric. One things escapes me. Are scipy and python redundant?  Should 
both be installed?

I'd installed numpy and matplotlib from source. Working right now on locating 
and remove all traces of those programs before re-installing. Can python 2.6 
that I installed through Synapic Package manager stay in place. Perhaps I 
should remove it too just to be sure everything works right?   

Mike--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] installed python-scipy causing errors with numpy

2012-02-18 Thread Michael Rawlins





 From: Eric Firing 
To: Michael Rawlins  
Cc: "matplotlib-users@lists.sourceforge.net" 
 
Sent: Saturday, February 18, 2012 3:57 PM
Subject: Re: [Matplotlib-users] installed python-scipy causing errors with numpy
 
On 02/18/2012 10:49 AM, Michael Rawlins wrote:
>
>
> 
> *From:* Eric Firing 
> *To:* matplotlib-users@lists.sourceforge.net
> *Sent:* Saturday, February 18, 2012 12:26 PM
> *Subject:* Re: [Matplotlib-users] installed python-scipy causing errors
> with numpy
>
> On 02/18/2012 07:17 AM, Michael Rawlins wrote:
>  >
>  > A couple weeks ago I installed version 1.2 from sources, as described
> here:
>  >
>  > http://matplotlib.sourceforge.net/users/installing.html
>  >
>  > I'm running Ubuntu 10.04 LTS. Everything was working fine. Looks like
>  > numpy version 1.3 in place. A few minutes ago I installed python-scipy
>  > from the Ubuntu Synaptic package manager. Getting this any time I run a
>  > program:
>  >
>  > >python colorbar_testing.py <http://colorbar_testing.py>
>  > Traceback (most recent call last):
>  > File "colorbar_testing.py", line 5, in 
>  > from matplotlib import pyplot, mpl
>  > File "/usr/local/lib/python2.6/dist-packages/matplotlib/__init__.py",
>  > line 173, in 
>  > __version__numpy__, numpy.__version__))
>  > ImportError: numpy 1.4 or later is required; you have 1.3.0
>  >
>  >
>  > Version control with python, matplotlib, numpy, etc problematic when
>  > compiled from source? Shall I reinstall everything again, including
>  > python-scipy? What order? Thanks.
>
> You need to remove your numpy and scipy packages and install both of
> these from source (just use the most recent releases), and then rebuild
> matplotlib. Numpy has to be installed before building either scipy or
> mpl, but mpl and scipy are independent of each other so either can be
> built once a suitable numpy is there.
>
> Eric
>
>
>
> Thanks Eric. One things escapes me. Are scipy and python redundant?
> Should both be installed?
>
> I'd installed numpy and matplotlib from source. Working right now on
> locating and remove all traces of those programs before re-installing.
> Can python 2.6 that I installed through Synapic Package manager stay in
> place. Perhaps I should remove it too just to be sure everything works
> right?

No!  The python 2.6 package is perfectly fine.  Try to remove that, and 
you are likely to hose your whole system.  It sounds like your only 
problem was that you had the numpy package installed, and it was being 
found instead of the one installed from source.

Eric


I don't understand what you mean when you say "...you had the numpy package 
installed,.."  Are you saying a version of numpy came along with scipy, and 
that was the one "being found"?   Also, to run programs which need scipy.stats 
I'll have to again install scipy. When I did that using Synaptic it broke my 
system. In summary, I don't understand what caused the problem. Shall I install 
scipy from source?

The version of numpy I installed last month from source is 1.61.  I've just 
found a couple files:

/usr/bin/numpy-1.6.1/doc/release/1.3.0-notes.rst
/usr/lib/python2.6/dist-packages/numpy-1.3.0.egg-info. 

I'll assume those numbers 1.3.0 are not an issue.

Mike--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] installed python-scipy causing errors with numpy

2012-02-18 Thread Michael Rawlins




 From: Eric Firing 
To: Michael Rawlins  
Cc: "matplotlib-users@lists.sourceforge.net" 
 
Sent: Saturday, February 18, 2012 5:42 PM
Subject: Re: [Matplotlib-users] installed python-scipy causing errors with numpy
 
On 02/18/2012 11:54 AM, Michael Rawlins wrote:
>
>
> The version of numpy I installed last month from source is 1.61. I've
> just found a couple files:
>
> /usr/bin/numpy-1.6.1/doc/release/1.3.0-notes.rst

This looks wrong.  Did you untar the tarball in /usr/bin?  Don't.  Untar 
it in some non-system location, maybe a subdirectory of your home 
directory, and then

cd numpy
python setup.py build
sudo python setup.py install


Thanks. Yes, I did untar numpy.tar in /usr/bin.  Won't do that again. When I 
installed matplotlib I untared that tarball in a subdirectory of my home 
directory.  

Any suggestions for being sure I completely remove all potentially conflicting 
traces of numpy and matplotlib before reinstall? I usually use the locate 
command to find files with those names in them. As you know, the files are most 
often found in just a few directories.

Mike
--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] show() does not pop up a window

2012-02-21 Thread Michael Rawlins


I've just installed numpy 1.6 and matplotlib 1.0.0 from source code on two 
linux machines, both running linux Ubuntu OS with python installed from 
Synaptic Package Manager. I've noticed no anomalies one machine. On the second 
machine, graphic window does not pop up. I'm run python non-interactively. For 
example:

> python demo_axes_grid.py

returns to command prompt without error on misbehaving machine. That same 
standard program works fine on the other machine. Interestingly, everything was 
working fine yesterday under version 0.99.

Mike--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] show() does not pop up a window

2012-02-21 Thread Michael Rawlins




 From: Benjamin Root 
To: Michael Rawlins  
Cc: "matplotlib-users@lists.sourceforge.net" 
 
Sent: Tuesday, February 21, 2012 3:37 PM
Subject: Re: [Matplotlib-users] show() does not pop up a window
 




On Tue, Feb 21, 2012 at 2:28 PM, Michael Rawlins  wrote:


>
>I've just installed numpy 1.6 and matplotlib 1.0.0 from source code on two 
>linux machines, both running linux Ubuntu OS with python installed from 
>Synaptic Package Manager. I've noticed no anomalies one machine. On the second 
>machine, graphic window does not pop up. I'm run python non-interactively. For 
>example:
>
>
>> python demo_axes_grid.py
>
>
>returns to command prompt without error on misbehaving machine. That same 
>standard program works fine on the other machine. Interestingly, everything 
>was working fine yesterday under version 0.99.
>
>
>Mike
>
>
>

Mike,

At the very least, please try out v1.0.1, but I recommend v1.1.0.  These 
releases contains many fixes to the show() behavior.  If it still doesn't work, 
could you please attach your mpl build log?

Ben Root


I've removed v1.0.0 and installed v1.1.0.  Tried Eric's suggestion.

>python
Python 2.6.4 (r264:75706, Dec  7 2009, 18:45:15) 
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> print matplotlib.get_backend()
agg
>>> 


Then quit python and ran demo.

>python demo_axes_grid.py

No plot window came up. 

Ben:  Where is the build log?  A file name?  Does the build require and option 
to be given to produce the log?

Mike--
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Taylor diagram (2nd take)

2012-03-27 Thread Michael Rawlins


self._ax.grid

is in the code I have.  


Jae-Joon: Yannick must have modified the code beyond the version to which you 
refer.

Mike




 From: Jae-Joon Lee 
To: Yannick Copin  
Cc: Michael Rawlins ; 
matplotlib-users@lists.sourceforge.net 
Sent: Monday, March 26, 2012 9:38 PM
Subject: Re: [Matplotlib-users] Taylor diagram (2nd take)
 
On Wed, Feb 22, 2012 at 12:10 AM, Yannick Copin
 wrote:
> after iterating with Michael A. Rawlins over my previous attempt to code a
> Taylor diagram (see [1]), here's a new version of my code, along with an
> example plot. Maybe it could make its way into the gallery as an example of
> Floating Axes and Grid Finder (even though I'm not sure the code is
> particularly exemplary, comments are welcome).

Good to know that someone is using axisartist toolkit.
Just a quick comment.


    def add_grid(self, *args, **kwargs):
        """Add a grid."""

        self.ax.grid(*args, **kwargs)


Maybe you wanted "self._ax.grid"?

Regards,

-JJ

--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users--
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] plotting a colored symbol with plot command

2012-08-24 Thread Michael Rawlins


Relatively new user here. I need to place a series of white colored dots on a 
map. I've been able to place black dots using:

plt.plot(x,y,color='k',marker='.',markersize=3.0)

The color option in this command does not plot the chosen color, only black. 
The command:

plt.plot(x,y,'wo')

places white dots with black around the edges.  I see that the 'w' is for white 
and 'o' is for the symbol. I'd like to use the former command since that gives 
me control over marker size and a dot without a black edge.

Lastly, it's not clear to me if I should be using plt.plot or just plot. Both 
work, and I don't know the difference. 
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting a colored symbol with plot command

2012-08-24 Thread Michael Rawlins





 From: Damon McDougall 
To: Michael Rawlins  
Cc: "matplotlib-users@lists.sourceforge.net" 
 
Sent: Friday, August 24, 2012 4:22 PM
Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command
 
On Fri, Aug 24, 2012 at 09:20:47PM +0100, Damon McDougall wrote:
> Hey Michael!
> 
> Welcome :)
> 
> On Fri, Aug 24, 2012 at 01:00:13PM -0700, Michael Rawlins wrote:
> > 
> > Relatively new user here. I need to place a series of white colored dots on 
> > a map. I've been able to place black dots using:
> > 
> > plt.plot(x,y,color='k',marker='.',markersize=3.0)
> >
> 
> You can change the colour with:
> 
> plt.pyplot(x, y, color='g', marker='.', markersize=3.0)
> 
> That will plot a green dot.


Damon,

plt.pyplot gives an error:

AttributeError: 'module' object has no attribute 'pyplot'

If I use plt.plot(x, y, color='g', marker='.', markersize=3.0)

the dots are black. But I've found success with:

plt.plot(x,y,'wo',markeredgecolor='white',markersize=3.0)

so all is well. Thanks for your help.

> 
> > 
> > The color option in this command does not plot the chosen color, only 
> > black. The command:
> > 
> > plt.plot(x,y,'wo')
> >
> 
> You can change the colour of the edge with the 'markeredgecolour'
>

-- 
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting a colored symbol with plot command

2012-08-25 Thread Michael Rawlins





 From: Damon McDougall 
To: Michael Rawlins  
Cc: "matplotlib-users@lists.sourceforge.net" 
 
Sent: Saturday, August 25, 2012 4:21 AM
Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command
 
On Fri, Aug 24, 2012 at 02:39:12PM -0700, Michael Rawlins wrote:
> 
> 
> 
> 
> 
>  From: Damon McDougall 
> To: Michael Rawlins  
> Cc: "matplotlib-users@lists.sourceforge.net" 
>  
> Sent: Friday, August 24, 2012 4:22 PM
> Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command
>  
> On Fri, Aug 24, 2012 at 09:20:47PM +0100, Damon McDougall wrote:

> 
> If I use plt.plot(x, y, color='g', marker='.', markersize=3.0)
> 
> the dots are black.

That should not happen... Have you tried some of the other colours? 'r',
'b', 'm', 'y', 'c'? Are they all black? What are you saving the file as? What
is the output of:

plt.get_backend()


Yes I've tried several. All produce black dots. The output of that command is 
'agg'.  I use:

plt.savefig('map.eps')

to produce eps images.




-- 
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting a colored symbol with plot command

2012-08-27 Thread Michael Rawlins





 From: Warren Weckesser 
To: "matplotlib-users@lists.sourceforge.net" 
 
Sent: Saturday, August 25, 2012 11:13 AM
Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command
 




On Sat, Aug 25, 2012 at 9:59 AM, Michael Rawlins  wrote:


>
>
>
>
>
> From: Damon McDougall 
>To: Michael Rawlins  
>Cc: "matplotlib-users@lists.sourceforge.net" 
> 
>Sent: Saturday, August 25, 2012 4:21 AM
>Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command
> 
>On Fri, Aug 24, 2012 at 02:39:12PM -0700, Michael Rawlins wrote:
>> 
>> 
>> 
>> 
>> 
>>  From: Damon McDougall 
>> To: Michael Rawlins  
>> Cc: "matplotlib-users@lists.sourceforge.net" 
>>  
>> Sent: Friday, August 24, 2012 4:22 PM
>> Subject: Re: [Matplotlib-users] plotting a colored symbol with plot command
>>  
>> On Fri, Aug 24, 2012 at 09:20:47PM +0100,
 Damon McDougall wrote:
>
>> 
>> If I use plt.plot(x, y, color='g', marker='.', markersize=3.0)
>> 
>> the dots are black.
>
>That should not happen... Have you tried some of the other colours? 'r',
>'b', 'm', 'y', 'c'? Are they all black? What are you saving the file as? What
>is the output of:
>
>plt.get_backend()
>
>
>Yes I've tried several. All produce black dots. The output of that command is 
>'agg'.  I use:
>
>plt.savefig('map.eps')
>
>to produce eps images.
>
>


The default 'markeredgecolor' (or 'mec') is black, and with small dots, 
you will see more edge color than face color.  To test this, create the 
same plot but with an exaggerated marker size, e.g. markersize=30.  If 
that is the problem, you can fix it by also setting the edge color to 
green, e.g. mec='g'.

Warren


[Sending to the list this time--forgot to "reply to all" the first time.]


Success.  I've made the markers larger. The correct color is being plotted. As 
Warren suggested, without specifying markeredgecolor I see mostly black border 
with the smaller marker size. Thanks to all for the help.  


 
--
>Live Security Virtual Conference
>Exclusive live event will cover all the ways today's security and
>threat landscape has changed and how IT managers can respond. Discussions
>will include endpoint security, mobile security and the latest in malware
>threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>___
>Matplotlib-users mailing list
>Matplotlib-users@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] error installing basemap

2012-09-13 Thread Michael Rawlins


Following instructions here:

http://matplotlib.org/basemap/users/installing.html

Got this error and termination after issuing python setup.py install from the 
basemap directory.


src/_proj.c:4:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: Command "gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall 
-Wstrict-prototypes -fPIC -Isrc 
-I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 
-c src/_proj.c -o build/temp.linux-i686-2.7/src/_proj.o" failed with exit 
status 1



I'm running a new installation of Ubuntu 12.04. I installed Python and 
Matplotlib through package manager. Several examples tested fine. I see no 
Python.h file on my system. Thanks in advance for suggestions.

MR--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] error installing basemap

2012-09-13 Thread Michael Rawlins





 From: Michael Droettboom 
To: matplotlib-users@lists.sourceforge.net 
Sent: Thursday, September 13, 2012 2:09 PM
Subject: Re: [Matplotlib-users] error installing basemap
 

You need to also install the python development package (python-dev), which 
contains the headers.  

Mike



OK basemap installed.  Thanks. But I'm getting an error running a script that 
worked with previous installation(s) of python, matplotlib, and basemap. The 
error:

user@comsys:~>python map2_TempDiff_4panels.py
Traceback (most recent call last):
  File "map2_TempDiff_4panels.py", line 27, in 
    from mpl_toolkits.basemap import  NetCDFFile
ImportError: cannot import name NetCDFFile


I installed python-mpltoolkits.basemap from package manager, before testing my 
script.

MR







>
>
>--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
>
>___
Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/matplotlib-users 

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] error installing basemap

2012-09-13 Thread Michael Rawlins






 From: Michael Droettboom 
To: matplotlib-users@lists.sourceforge.net 
Sent: Thursday, September 13, 2012 2:09 PM
Subject: Re: [Matplotlib-users] error installing basemap
 

You need to also install the python development package (python-dev), which 
contains the headers.  

Mike






 From: Michael Rawlins 
To: Michael Droettboom ; 
"matplotlib-users@lists.sourceforge.net" 
 
Sent: Thursday, September 13, 2012 3:11 PM
Subject: Re: [Matplotlib-users] error installing basemap
ailing list Matplotlib-users@lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


OK basemap installed.  Thanks. But I'm getting an error running a script that 
worked with previous installation(s) of python, matplotlib, and basemap. The 
error:

user@comsys:~>python map2_TempDiff_4panels.py
Traceback (most recent call last):
  File "map2_TempDiff_4panels.py", line 27, in 
    from mpl_toolkits.basemap import  NetCDFFile
ImportError: cannot import name NetCDFFile


I installed python-mpltoolkits.basemap from package manager, before testing my 
script.

MR


An update:  My test script, which works with previously, now gets past the 
header initializations. Here they are:

import sys,getopt
from mpl_toolkits.basemap import Basemap, shiftgrid, cm 
#from mpl_toolkits.basemap import  NetCDFFile
from Scientific.IO.NetCDF import NetCDFFile
from pylab import *
import  matplotlib.pyplot as plt


Notr clear why the first import NetCDFFile statement does not work. Farther 
down the script, the code stops on this statement:

data.missing_value=-9.99

There error to standard output:

Traceback (most recent call last):
  File "map2_TempDiff_4panels.py", line 266, in 
    data.missing_value=-9.99
IOError: netcdf: write access to read-only file




 



--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] error installing basemap

2012-09-13 Thread Michael Rawlins





 From: Jeff Whitaker 
To: matplotlib-users@lists.sourceforge.net 
Cc: rawlin...@yahoo.com 
Sent: Thursday, September 13, 2012 9:44 PM
Subject: Re: [Matplotlib-users] error installing basemap
 

On 9/13/12 2:34 PM, Michael Rawlins wrote:


>
>
>
>
>
> From: Michael Droettboom 
>To: matplotlib-users@lists.sourceforge.net 
>Sent: Thursday, September 13, 2012 2:09 PM
>Subject: Re: [Matplotlib-users] error installing basemap
>
>
>You need to also install the python development package (python-dev), which 
>contains the headers.  
>
>Mike
>
>
>
>
>
>
>
>
> From: Michael Rawlins 
>To: Michael Droettboom ; 
>"matplotlib-users@lists.sourceforge.net" 
> 
>Sent: Thursday, September 13, 2012 3:11 PM
>Subject: Re: [Matplotlib-users] error installing basemap
>ailing list Matplotlib-users@lists.sourceforge.net 
>https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>OK basemap installed.  Thanks. But I'm
getting an error running a script that
worked with previous installation(s) of
python, matplotlib, and basemap. The error:
>
>user@comsys:~>python map2_TempDiff_4panels.py
>Traceback (most recent call last):
>  File "map2_TempDiff_4panels.py", line 27,
in 
>    from mpl_toolkits.basemap import 
NetCDFFile
>ImportError: cannot import name NetCDFFile
>
>
>I installed python-mpltoolkits.basemap from
package manager, before testing my script.
>
>MR
>
>
>An update:  My test script, which works with
previously, now gets past the header
initializations. Here they are:
>
>import sys,getopt
>from mpl_toolkits.basemap import Basemap,
shiftgrid, cm 
>#from mpl_toolkits.basemap import 
NetCDFFile
>from Scientific.IO.NetCDF import NetCDFFile
>from pylab import *
>import  matplotlib.pyplot as plt
>
>
>Notr clear why the first import NetCDFFile
statement does not work. Farther down the
script, the code stops on this statement:
>
>data.missing_value=-9.99
>
>There error to standard output:
>
>Traceback (most recent call last):
>  File "map2_TempDiff_4panels.py", line 266,
in 
>    data.missing_value=-9.99
>IOError: netcdf: write access to read-only
file
>
>
Michael:  The NetCDFFile function was deprecated a few releases
back, and recently removed.  If you have netcdf4-python installed
you can do

from netCDF4 import Dataset as NetCDFFile

and the script should work as before.

Regarding the second error, you must open the file for write access
(mode='w') if you want to add attributes to the data variables.

-Jeff


Jeff,

No I don't have netCDF4 installed. It's not in the package manager. Wasn't sure 
if there would be a conflict with python-netcdf that's installed. Guess that's 
the reverse interface. Now I'm having some trouble compiling netcdf4-python 
from sources following:

http://code.google.com/p/netcdf4-python/wiki/UbuntuInstall

The configure ended in error:

checking whether the C compiler works... no
configure: error: in `/home/rawlins/Downloads/netcdf-4.2.1.1':
configure: error: C compiler cannot create executables
  

Mike--
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] error installing basemap

2012-09-13 Thread Michael Rawlins








 From: Jeff Whitaker 
To: matplotlib-users@lists.sourceforge.net 
Cc: rawlin...@yahoo.com 
Sent: Thursday, September 13, 2012 9:44 PM
Subject: Re: [Matplotlib-users] error installing basemap
 


Michael:  The NetCDFFile function was deprecated a few releases back, and 
recently removed.  If you have netcdf4-python installed you can do

from netCDF4 import Dataset as NetCDFFile

and the script should work as before.

Regarding the second error, you must open the file for write access
(mode='w') if you want to add attributes to the data variables.

-Jeff



From: Michael Rawlins 
To: Jeff Whitaker ; 
"matplotlib-users@lists.sourceforge.net" 
 
Sent: Thursday, September 13, 2012 10:28 PM
Subject: Re: [Matplotlib-users] error installing basemap

Making some progress. Following here:

http://code.google.com/p/netcdf4-python/wiki/UbuntuInstall

I've installed HDF5 after installing build-essential package. With just gcc 
installed I got an error.

The ./configure in netcdf4 directory failed, but completed with 
--disable-netcdf-4. I went ahead anyway hoping I don't need netCDF-4 formats or 
the additional netCDF-4 functions. Besides that issue, what's also not clear is 
where is setup.py file for the last step. It is not in the netcdf directory 
after the make install finished.  I assume netcdf-python package will not 
conflict with the python-netcdf and netcdf versions installed through package 
manager.  

Mike




--
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users--
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] error installing basemap

2012-09-18 Thread Michael Rawlins




 From: Jeff Whitaker 
To: matplotlib-users@lists.sourceforge.net 
Cc: rawlin...@yahoo.com 
Sent: Thursday, September 13, 2012 9:44 PM
Subject: Re: [Matplotlib-users] error installing basemap
 


Michael:  The NetCDFFile function was deprecated a few releases back, and 
recently removed.  If you have netcdf4-python installed you can do

from netCDF4 import Dataset as NetCDFFile

and the script should work as before.

Regarding the second error, you must open the file for write access
(mode='w') if you want to add attributes to the data variables.

-Jeff



From: Michael Rawlins 
To: Jeff Whitaker ; 
"matplotlib-users@lists.sourceforge.net" 
 
Sent: Thursday, September 13, 2012 10:28 PM
Subject: Re: [Matplotlib-users] error installing basemap

Making some progress. Following here:

http://code.google.com/p/netcdf4-python/wiki/UbuntuInstall

I've installed HDF5 after installing build-essential package. With just gcc 
installed I got an error.

The ./configure in netcdf4 directory failed, but completed with 
--disable-netcdf-4. I went ahead anyway hoping I don't need netCDF-4 formats or 
the additional netCDF-4 functions. Besides that issue, what's also not clear is 
where is setup.py file for the last step. It is not in the netcdf directory 
after the make install finished.  I assume netcdf-python package will not 
conflict with the python-netcdf and netcdf versions installed through package 
manager.  

Mike




________
 From: Michael Rawlins 
To: "matplotlib-users@lists.sourceforge.net" 
 
Sent: Friday, September 14, 2012 1:34 AM
Subject: Re: [Matplotlib-users] error installing basemap
 


Got sidetracked with an OS issue. Back on the case.  Where is the setup.py file 
I'm to install?  I've installed both HDF5 and netcdf-4, correctly I hope. 


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



-
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] netcdf4-python build

2012-09-19 Thread Michael Rawlins


Ubuntu 12.04

hdf5-tools installed from package manager

netcdf-bin and python-netcdf installed from package manager

I downloaded netCDF4-1.0fix1.tar.gz from 
http://code.google.com/p/netcdf4-python/downloads/list

> python setup.py build


/usr/bin/ld: cannot find -lhdf5_hl
/usr/bin/ld: cannot find -lhdf5
collect2: ld returned 1 exit status
/usr/bin/ld: cannot find -lhdf5_hl
/usr/bin/ld: cannot find -lhdf5
collect2: ld returned 1 exit status
error: Command "gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions 
-Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-i686-2.7/netCDF4.o 
-L/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -Wl,-R/usr/local/lib 
-lnetcdf -lhdf5_hl -lhdf5 -lz -o build/lib.linux-i686-2.7/netCDF4.so" failed 
with exit status 1--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] netcdf4-python build

2012-09-19 Thread Michael Rawlins





 From: Jeff Whitaker 
To: Michael Rawlins ; Matplotlib Users 
 
Sent: Wednesday, September 19, 2012 2:35 PM
Subject: Re: [Matplotlib-users] netcdf4-python build
 

On 9/19/12 11:30 AM, Michael Rawlins wrote:


>
>Ubuntu 12.04
>
>
>hdf5-tools installed from package manager
>
>
>netcdf-bin and python-netcdf installed from package manager
>
>
>I downloaded netCDF4-1.0fix1.tar.gz from 
>http://code.google.com/p/netcdf4-python/downloads/list
>
>
>> python setup.py build
>
>
>
>
>/usr/bin/ld: cannot find -lhdf5_hl
>/usr/bin/ld: cannot find -lhdf5
>collect2: ld returned 1 exit status
>/usr/bin/ld: cannot find -lhdf5_hl
>/usr/bin/ld: cannot find -lhdf5
>collect2: ld returned 1 exit status
>error: Command "gcc -pthread -shared -Wl,-O1
  -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro
  build/temp.linux-i686-2.7/netCDF4.o -L/usr/local/lib
  -L/usr/local/lib -Wl,-R/usr/local/lib -Wl,-R/usr/local/lib
  -lnetcdf -lhdf5_hl -lhdf5 -lz -o
  build/lib.linux-i686-2.7/netCDF4.so" failed with exit status 1
>
>
>
Michael:  You're missing the hdf5 library.  You should be able to
install that (along with the netcdf version 4 library) using the
Ubuntu package manager. I don't know what the relevant package names
are.

See the docs at netcdf4-python.googlecode.com for installation instructions 
(including how to install the dependencies).  

You can also file a help request there and I'll see it (since this
is not really a basemap issue).

-Jeff


Just installed h5utils from package manager. Getting same errors.  In package 
manager I'm searching on hdf5.  If there's a package there I'm missing, then it 
certainly is not obvious.

Mike


-- 
Jeffrey S. Whitaker Phone  : (303)497-6313
Meteorologist   FAX: (303)497-6449
NOAA/OAR/PSD  R/PSD1Email  : jeffrey.s.whita...@noaa.gov 325 Broadway   
 Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg --
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] netcdf4-python build

2012-09-19 Thread Michael Rawlins





 From: Johann Rohwer 
To: matplotlib-users@lists.sourceforge.net 
Sent: Wednesday, September 19, 2012 3:22 PM
Subject: Re: [Matplotlib-users] netcdf4-python build
 
On 19/09/2012 21:14, Michael Rawlins wrote:

> Just installed h5utils from package manager. Getting same errors.  In
> package manager I'm searching on hdf5.  If there's a package there I'm
> missing, then it certainly is not obvious.

Try

libhdf5-serial
libhdf5-serial-dev
Johann



After installing those two packages I was able build with setup.py in 
netCDF4-1.0/

Last few lines of the build:

creating build/scripts.linux-i686-2.7
copying and adjusting utils/nc3tonc4 -> build/scripts.linux-i686-2.7
copying and adjusting utils/nc4tonc3 -> build/scripts.linux-i686-2.7
changing mode of build/scripts.linux-i686-2.7/nc3tonc4 from 644 to 755
changing mode of build/scripts.linux-i686-2.7/nc4tonc3 from 644 to 755


Here is my initialization:

from mpl_toolkits.basemap import Basemap, shiftgrid, cm 
from netCDF4 import Dataset as NetCDFFile

Here is result of execution of script:

Traceback (most recent call last):
  File "map_PrcpBias_Northeast.py", line 21, in 
    from netCDF4 import Dataset as NetCDFFile 

I understand using the python-netcdf package is an option. Installed that but 
am getting an eror saying missing libhdf5_hl.so.6 when trying:

from Scientific.IO.NetCDF import NetCDFFile

MR



--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] netcdf4-python build

2012-09-19 Thread Michael Rawlins





>
> From: Jeff Whitaker 
>To: Michael Rawlins  
>Sent: Wednesday, September 19, 2012 4:57 PM
>Subject: Re: [Matplotlib-users] netcdf4-python build
> 
>
>On 9/19/12 2:43 PM, Michael Rawlins wrote:
>
>
>>
>>
>>
>>
>>
>> From: Johann Rohwer 
>>To: matplotlib-users@lists.sourceforge.net 
>>Sent: Wednesday, September 19, 2012 3:22 PM
>>Subject: Re: [Matplotlib-users] netcdf4-python build
>> 
>>On 19/09/2012 21:14, Michael Rawlins wrote:
>>
>>> Just installed h5utils from package manager. Getting
same errors.  In
>>> package manager I'm searching on hdf5.  If there's a
package there I'm
>>> missing, then it certainly is not obvious.
>>
>>Try
>>
>>libhdf5-serial
>>libhdf5-serial-dev
>>Johann
>>
>>
>>
>>After installing those two packages I was able build with setup.py in 
>>netCDF4-1.0/
>>
>>Last few lines of the build:
>>
>>creating build/scripts.linux-i686-2.7
>>copying and adjusting utils/nc3tonc4 ->
build/scripts.linux-i686-2.7
>>copying and adjusting utils/nc4tonc3 ->
build/scripts.linux-i686-2.7
>>changing mode of build/scripts.linux-i686-2.7/nc3tonc4 from
644 to 755
>>changing mode of build/scripts.linux-i686-2.7/nc4tonc3 from
644 to 755
>>
>>
>>Here is my initialization:
>>
>>from mpl_toolkits.basemap import Basemap, shiftgrid, cm 
>>from netCDF4 import Dataset as NetCDFFile
>>
>>Here is result of execution of script:
>>
>>Traceback (most recent call last):
>>  File "map_PrcpBias_Northeast.py", line 21, in 
>>    from netCDF4 import Dataset as NetCDFFile 
>>
>Michael:  Please include the full traceback - what you posted
doesn't really tell us anything.
>
>
>How is full traceback obtained?
>
>
>
>
>>I understand using the python-netcdf package is an option.
Installed that but am getting an eror saying missing
libhdf5_hl.so.6 when trying:
>>
Do you have libhdf5_hl.so anywhere on your system after installing the 
libhdf5-serial package?  According to this
>
>http://packages.ubuntu.com/lucid/i386/libhdf5-serial-1.8.4/filelist
>
>it should be installed in /usr/lib.
>
>
>Yes it is in /usr/lib.
>
>
>Also, if I read this
>
>http://packages.ubuntu.com/natty/libnetcdf6
>
>correctly, just installing the libnetcdf6 and libnetcdf-dev packages
should be all you need to do - they depend on libhdf5-serial.
>
>-Jeff
>
>
>Both packages are installed.
>
>MR
>
>
>
>>from Scientific.IO.NetCDF import NetCDFFile
>>
>>MR
>>
>>
>>
>>--
>>Live Security Virtual Conference
>>Exclusive live event will cover all the ways today's
security and 
>>threat landscape has changed and how IT managers can
respond. Discussions 
>>will include endpoint security, mobile security and the
latest in malware 
>>threats.
http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>___
>>Matplotlib-users mailing list
>>Matplotlib-users@lists.sourceforge.net
>>https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>>
>>
>>
>>--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>
>>
>>___
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/PSD1Email  : jeffrey.s.whita...@noaa.gov 325 Broadway   
 Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg 
>
>--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] netcdf4-python build

2012-09-19 Thread Michael Rawlins



>
> From: Jeff Whitaker 
>To: Michael Rawlins  
>Cc: "matplotlib-users@lists.sourceforge.net" 
> 
>Sent: Wednesday, September 19, 2012 5:57 PM
>Subject: Re: [Matplotlib-users] netcdf4-python build
> 
>
>On 9/19/12 3:29 PM, Michael Rawlins wrote:
>
>
>>
>>How is full traceback obtained?
>>>
>Michael:  I just meant for you to paste the full output, not just
the first three lines.
>
>
>That's all that appears at standard output and I do not know how to 
>generate/find anything else.
>
>
>Since you apparently have all the libs installed, I don't understand
what's going on.  Please try deleting the netcdf4-python build
directory, and then run 'python setup.py build' again, capturing the
output in a file.  Send me that file off-list and I'll see if I can
suggest something.
>
>-Jeff
>
>
>Out of build, after removing build/ directory:
>
>HDF5_DIR environment variable not set, checking some standard locations ..
>checking /home/rawlins ...
>checking /usr/local ...
>HDF5 found in /usr/local
>
>NETCDF4_DIR environment variable not set, checking standard locations.. 
>checking /home/rawlins ...
>checking /usr/local ...
>netCDF4 found in /usr/local
>running build
>running config_cc
>unifing config_cc, config, build_clib, build_ext, build commands --compiler 
>opti
>ons
>running config_fc
>unifing config_fc, config, build_clib, build_ext, build commands --fcompiler 
>opt
>ions
>running build_src
>build_src
>building py_modules sources
>building extension "netCDF4" sources
>build_src: building npy-pkg config files
>running build_py
>creating build
>creating build/lib.linux-i686-2.7
>copying netcdftime.py -> build/lib.linux-i686-2.7
>copying netCDF4_utils.py -> build/lib.linux-i686-2.7
>copying ordereddict.py -> build/lib.linux-i686-2.7
>running build_ext
>customize UnixCCompiler
>customize UnixCCompiler using build_ext
>building 'netCDF4' extension
>compiling C sources
>C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall 
>-Wst
>rict-prototypes -fPIC
>
>creating build/temp.linux-i686-2.7
>compile options: '-I/usr/local/include -I/usr/local/include 
>-I/usr/lib/python2.7
>/dist-packages/numpy/core/include -I/usr/include/python2.7 -c'
>gcc: netCDF4.c
>netCDF4.c: In function '__pyx_f_7netCDF4__find_cmptype':
>netCDF4.c:46724:13: warning: '__pyx_v_xtype' may be used uninitialized in this 
>f
>unction [-Wuninitialized]
>netCDF4.c:37881:11: note: '__pyx_v_xtype' was declared here
>gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions 
>-
>Wl,-z,relro build/temp.linux-i686-2.7/netCDF4.o -L/usr/local/lib 
>-L/usr/local/li
>b -Wl,-R/usr/local/lib -Wl,-R/usr/local/lib -lnetcdf -lhdf5_hl -lhdf5 -lz -o 
>bui
>ld/lib.linux-i686-2.7/netCDF4.so
>running scons
>running build_scripts
>creating build/scripts.linux-i686-2.7
>copying and adjusting utils/nc3tonc4 -> build/scripts.linux-i686-2.7
>copying and adjusting utils/nc4tonc3 -> build/scripts.linux-i686-2.7
>changing mode of build/scripts.linux-i686-2.7/nc3tonc4 from 644 to 755
>changing mode of build/scripts.linux-i686-2.7/nc4tonc3 from 644 to 755
>
>--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] netcdf4-python build

2012-09-21 Thread Michael Rawlins

After the build, I determined that 'install' was also needed.

> python setup.py install

completed with no errors.  OK, finally built and installed. But now my 
matplotlib script gives this error:

Traceback (most recent call last):
  File "map_PrcpBias_Northeast.py", line 21, in 
    from netCDF4 import Dataset as NetCDFFile 
ImportError: /usr/local/lib/python2.7/dist-packages/netCDF4.so: undefined 
symbol: nc_inq_var_endian


So, checking shared library dependencies:

> ldd /usr/local/lib/python2.7/dist-packages/netCDF4.so

    linux-gate.so.1 =>  (0xb776a000)
    libnetcdf.so.7 => /usr/local/lib/libnetcdf.so.7 (0xb7604000)
    libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb75d3000)
    libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb742d000)
    libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb7401000)
    /lib/ld-linux.so.2 (0xb776b000)

and

> ldd /usr/local/lib/libnetcdf.so.7

    linux-gate.so.1 =>  (0xb7765000)
    libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb7663000)
    libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb74be000)
    /lib/ld-linux.so.2 (0xb7766000)

no libhdf5 there. Can this be fixed?

MR--
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] netcdf4-python build

2012-09-21 Thread Michael Rawlins





>
> From: Damon McDougall 
>To: Michael Rawlins  
>Cc: "matplotlib-users@lists.sourceforge.net" 
> 
>Sent: Friday, September 21, 2012 2:50 PM
>Subject: Re: [Matplotlib-users] netcdf4-python build
> 
>
>
>
>From what I remember dealing with the netcdf c library, you have to explicitly 
>set a compile flag to enable hdf5 support. That was a while ago, though. I'm 
>not sure if things have changed.
>
>
>Hope this helps.
>
>
>
>
>I did not do a source compile. 
>
>I've reinstalled libhdf5-serial-1.8.4 package and now have the right HDF5 
>library files. Successfully built and installed netCDF4-1.0.  My script loads 
>in module but a read/write issue is present. This is code that worked on 
>previous system. Error:
>
>  File "test.py", line 96, in 
>    data.missing_value=-9.99
>  File "netCDF4.pyx", line 2570, in netCDF4.Variable.__setattr__ 
>(netCDF4.c:28242)
>  File "netCDF4.pyx", line 2392, in netCDF4.Variable.setncattr 
>(netCDF4.c:26309)
>  File "netCDF4.pyx", line 1013, in netCDF4._set_att (netCDF4.c:12699)
>AttributeError: NetCDF: Write to read only
>
>
>The statement in the code triggers the error.
>
>data.missing_value=-9.99 .
>
>MR
>--
How fast is your code?
3 out of 4 devs don\\\'t know how their code performs in production.
Find out how slow your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219672;13503038;z?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] error reading netcdf file

2012-09-26 Thread Michael Rawlins
Recently built and installed netCDF4-1.0.  I'm running a script that has worked 
on two other linux OS systems. Error:

File "test.py", line 96, in 
    data.missing_value=-9.99
  File "netCDF4.pyx", line 2570, in netCDF4.Variable.__setattr__ 
(netCDF4.c:28242)
  File "netCDF4.pyx", line 2392, in netCDF4.Variable.setncattr (netCDF4.c:26309)
  File "netCDF4.pyx", line 1013, in netCDF4._set_att (netCDF4.c:12699)
AttributeError: NetCDF: Write to read only


The statement in the code triggers the error is:

data.missing_value=-9.99 .

MR
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] error reading netcdf file

2012-09-26 Thread Michael Rawlins





>
> From: Benjamin Root 
>To: Michael Rawlins  
>Cc: "matplotlib-users@lists.sourceforge.net" 
> 
>Sent: Wednesday, September 26, 2012 10:33 AM
>Subject: Re: [Matplotlib-users] error reading netcdf file
> 
>
>
>
>
>On Wed, Sep 26, 2012 at 10:27 AM, Michael Rawlins  wrote:
>
>Recently built and installed netCDF4-1.0.  I'm running a script that has 
>worked on two other linux OS systems. Error:
>>
>>File "test.py", line 96, in 
>>    data.missing_value=-9.99
>>  File "netCDF4.pyx", line 2570, in netCDF4.Variable.__setattr__ 
>>(netCDF4.c:28242)
>>  File "netCDF4.pyx", line 2392, in netCDF4.Variable.setncattr 
>>(netCDF4.c:26309)
>>  File "netCDF4.pyx", line 1013, in netCDF4._set_att (netCDF4.c:12699)
>>AttributeError: NetCDF: Write to read only
>>
>>
>>The statement in the code triggers the error is:
>>
>>data.missing_value=-9.99 .
>>
>>MR
>>
>>
>
>
>This typically happens when one opens a netCDF4 Dataset object in 'r' mode, 
>and/or if the file permissions for the file was set to read-only.  When 
>modifying an attribute, it is technically trying to write to the file.
>
>Ben Root
>
>
>
>Here is the file open statement:
>
>ncfile = NetCDFFile('statsPrcp_Uncertainty2_winter.nc', 'r')
>
>This worked fine in earlier versions.  No where in the code do I try to write 
>to a netCDF file. So I'm confused as to why specifying the read of the netCDF 
>file would result in an error when designating the missing data value.
>
>Here's the code:
>
># Works with the netCDF files in the tutorial, and also the
># files available for download at:
># http://www.cdc.noaa.gov/cdc/data.ncep.reanalysis.html 
># Adapted from the basemap example plotmap_pcolor.py,
># Some of the variable names from that example are retained.
>#
># Uses basemap's pcolor function.  Pcolor accepts arrays
># of the longitude and latitude  points of the vertices on the pixels,
># as well as an array with the numerical value in the pixel. 
>
>verbose=0 #verbose=2 says a bit more
>
>import sys,getopt
>from mpl_toolkits.basemap import Basemap, shiftgrid, cm 
>from netCDF4 import Dataset as NetCDFFile 
>#from mpl_toolkits.basemap import  NetCDFFile
>from pylab import *
>import  matplotlib.pyplot as plt
>
>alloptions, otherargs= getopt.getopt(sys.argv[1:],'ro:p:X:Y:v:t:l:u:n:') # 
>note the : after o and p
>proj='lam'
>
>cmap = cm.get_cmap('jet_r', 10)    # 10 discrete colors
>
>print "\nPlotting, please wait...maybe more than 10 seconds"
>if proj=='lam': #Lambert Conformal
>    m = Basemap(llcrnrlon=-80.6,llcrnrlat=38.4,urcrnrlon=-66.0,urcrnrlat=47.7,\
>    resolution='l',area_thresh=1000.,projection='lcc',\
>    lat_1=65.,lon_0=-73.3)
>xtxt=20. #offset for text
>ytxt=20.
>parallels = arange(38.,48.,2.)
>meridians = arange(-80.,-64.,2.)
>
>xsize = rcParams['figure.figsize'][0]
>fig=figure(figsize=(xsize,m.aspect*xsize))
>#cax = axes([0.88, 0.1, 0.06, 0.81])  #  colorbar axes for map w/ graticule
>
>
>subplots_adjust(left=None, bottom=None, right=0.9, top=None, wspace=0.05, 
>hspace=0.03)
># Make the first map at upper left
>plt.subplot(2,2,1)
>
>ncfile = NetCDFFile('statsPrcp_Uncertainty2_winter.nc', 'r')
>
>xvar='rlon'
>print "shape of "+xvar+': ',ncfile.variables[xvar].shape
>if ncfile.variables[xvar][:].ndim ==1:
>    print "X is independent of Y"
>    lon1d=ncfile.variables[xvar][:]
>else:
>    lon1d=False
>    if  ncfile.variables[xvar][:].ndim ==2: lon2d=ncfile.variables[xvar][:]
>    if  ncfile.variables[xvar][:].ndim ==3: lon2d=ncfile.variables[xvar][0,:,:]
>    print "shape of lond2d:", lon2d.shape
>
>yvar='rlat'
>print "shape of "+yvar+': ',ncfile.variables[yvar].shape
>if ncfile.variables[yvar][:].ndim ==1:
>    print "Y is independent of X"
>    lat1d=ncfile.variables[yvar][:]
>else:
>    lat1d=False
>    if  ncfile.variables[yvar][:].ndim ==2: lat2d=ncfile.variables[yvar][:]
>    if  ncfile.variables[yvar][:].ndim ==3: 
>lat2d=ncfile.variables[yvar][0,:,:] 
>    print "shape of lat2d:", lat2d.shape
>
>thevar='diff'
>data=ncfile.variables[thevar]
>dataa=data[:]
>theshape=dataa.shape
>try:
>    add_offset=ncfile.var

Re: [Matplotlib-users] error reading netcdf file

2012-09-26 Thread Michael Rawlins


>
> From: Jeff Whitaker 
>To: Benjamin Root ; Michael Rawlins ; 
>Matplotlib Users  
>Sent: Wednesday, September 26, 2012 5:10 PM
>Subject: Re: [Matplotlib-users] error reading netcdf file
> 
>
>Michael:  You can't change an attribute in a read-only dataset.  It should 
>never have worked.
>
>-Jeff
>
>


Thanks Jeff and Ben.

Below is a complete version of one such program I use. I was give the program 
by a colleague and I do not know who wrote that code.  My previous post showed 
only as far as the missing data statement.


I'm relatively new to this software. It looks like the missing value goes into 
the maskdat array and maskdat is an input to pcolor function. Perhaps the best 
way is to get it working (shading a map) with just the array from the netCDF 
file read. Essentailly the missing value is to shade some grids outside the 
region white.  


Mike




#!/usr/bin/env python
# v0.5 19 June 2010
# General purpose plotter of 2-D gridded data from NetCDF files,
# plotted with map boundaries.
# NetCDF file should have data in either 2-D, 3-D or 4-D arrays.
# Works with the netCDF files in the tutorial, and also the
# files available for download at:
# http://www.cdc.noaa.gov/cdc/data.ncep.reanalysis.html 
# Adapted from the basemap example plotmap_pcolor.py,
# Some of the variable names from that example are retained.
#
# Uses basemap's pcolor function.  Pcolor accepts arrays
# of the longitude and latitude  points of the vertices on the pixels,
# as well as an array with the numerical value in the pixel. 

verbose=0 #verbose=2 says a bit more

import sys,getopt

from mpl_toolkits.basemap import Basemap, shiftgrid, cm 
#from netCDF3 import Dataset as NetCDFFile 
from mpl_toolkits.basemap import  NetCDFFile
from pylab import *

alloptions, otherargs= getopt.getopt(sys.argv[1:],'ro:p:X:Y:v:t:l:u:n:') # note 
the : after o and p
proj='lam'
#plotfile=None
#plotfile='testmap2.png'
usejetrev=False
colorbounds=[None,None]
extratext=""
xvar=None
yvar=None
thevar=None

thetitle='Bias - Winter Air Temperature'
#thetitle='Bias - Spring Air Temperature'
#thetitle='Bias - Summer Air Temperature'
#thetitle='Bias - Autumn Air Temperature'

therec=None
thelev=None
cbot=None
ctop=None
startlon=-180 #default assumption for starting longitude
for theopt,thearg in alloptions:
    print theopt,thearg
    if theopt=='-o': # -o needs filename after it, which is now thearg
        plotfile=thearg    
    elif theopt=='-p': 
        proj=thearg
    elif theopt=='-X': 
        xvar=thearg
    elif theopt=='-Y': 
        yvar=thearg
    elif theopt=='-v': 
        thevar=thearg
    elif theopt=='-t': 
        thetitle=thearg
    elif theopt=='-l': 
        cbot=thearg
    elif theopt=='-u': 
        ctop=thearg
    elif theopt=='-n': 
        therec=thearg
    elif theopt=='-m': 
        thelev=thearg
    elif theopt=='-r': 
        usejetrev=True
    else: #something went wrong
        print "hmm, what are these??? ", theopt, thearg
        sys.exit()


print otherargs
try:
    ncname=otherargs[0]
    ncfile = NetCDFFile(ncname, 'r')
except:
#    ncname = raw_input("\nenter NetCDF file name =>")
#    ncfile = NetCDFFile(ncname, 'r')
    ncfile = NetCDFFile('simple_xy.nc', 'r')   # Here's filename
    
if verbose>0:  #examine the NetCDF file
    print "GLOBAL ATTRIBUTES:"
    allattr=dir(ncfile)
    normalattr=dir(NetCDFFile('/tmp/throwaway.nc','w'))
    for item in allattr:
        if item not in normalattr: print item,': ',getattr(ncfile,item)
#    for name in ncfile.ncattrs():
#            print name,'=', getattr(ncfile,name)
#            if name=='Conventions' and getattr(ncfile,name)=='COARDS
':
#                nmcrean=True
#                startlon=0.
#                print "guessing this is an NMC reananalysis file
"
#            else:
#                nmcrean=False
    print "\n\nDIMENSIONS:"
    for name in ncfile.dimensions.keys():
        print "\nDIMENSION:",
        try:
            print name, ncfile.variables[name][:]
        except:
            print name, ncfile.dimensions[name]
        try:
            print '   ',ncfile.variables[name].units
        except:
            pass
        try:
            print '   ',ncfile.variables[name].gridtype
        except:
            pass
    print "\n'*'\nVARIABLES:"
    for name in ncfile.variables.keys():
        if name in ncfile.dimensions.keys(): continue
        print "\nVARIABLE:",
        print name, ncfile.variables[name].dimensions,
        try:
        

Re: [Matplotlib-users] error reading netcdf file

2012-09-27 Thread Michael Rawlins




- Original Message -
> From: Michael Rawlins 
> To: Jeff Whitaker ; Benjamin Root 
> ; Matplotlib Users 
> Cc: 
> Sent: Wednesday, September 26, 2012 6:23 PM
> Subject: Re: [Matplotlib-users] error reading netcdf file
> 
> 
> 
>> 
>>  From: Jeff Whitaker 
>> To: Benjamin Root ; Michael Rawlins 
> ; Matplotlib Users 
>  
>> Sent: Wednesday, September 26, 2012 5:10 PM
>> Subject: Re: [Matplotlib-users] error reading netcdf file
>> 
>> 
>> Michael:  You can't change an attribute in a read-only dataset.  It 
> should never have worked.
>> 
>> -Jeff
>> 
>> 
> 
> 
> Thanks Jeff and Ben.
> 
> Below is a complete version of one such program I use. I was give the program 
> by 
> a colleague and I do not know who wrote that code.  My previous post showed 
> only 
> as far as the missing data statement.
> 




I've gotten my script to work by setting the missing value another way. I'm 
showing lines commented out as well.

#data.missing_value=-9.99
#try:
#    mval=data.missing_value
#    print " using specified missing value =",mval
#except:
    mval=-9.99
#    print " faking missing value=",mval
# make a masked array: using missing value(s) in mval
maskdat=ma.masked_values(slice,mval)


If I understand correctly, in previous versions the value of -9.99 was passed 
through the data.missing_value into mval. A mistake in coding that did not 
result in an error.  I will implement the change. Tomorrow I'll check that this 
solution is backward compatible.

Mike

--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] error reading netcdf file

2012-09-27 Thread Michael Rawlins
>
> From: Benjamin Root 
>To: Michael Rawlins  
>Cc: Matplotlib Users  
>Sent: Thursday, September 27, 2012 2:29 PM
>Subject: Re: [Matplotlib-users] error reading netcdf file
> 
>
>Michael,
>
>The .missing_value attribute is not used anymore (It is ._FillValue now).  
>Anyway, if your data had any value that matched ._FillValue, then, by default, 
>netCDF4 will give you a masked array anyway.  You will only need to set the 
>mask if the fill value doesn't exist or if it is different from what you were 
>expecting.
>
>Ben Root
>
>
>

Thanks Ben. I'll play around with ._FillValue and masked arrays. Glad to have 
everything working again with this new OS.

Mike


--
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://ad.doubleclick.net/clk;258768047;13503038;j?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Good morning!

2013-06-20 Thread Michael Rawlins
 
http://bananajoestampabay.com/wp-content/themes/toolbox/youtube.php?cftzwj892mmzinhs.htm


























































































































rawlins02
Michael Rawlins
***
A man of principles. None of them interesting. -- John Dobbin
  --
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] defining a custom RGB colormap

2011-01-05 Thread Michael Rawlins

How does one define a range of colors for a custom user-defined colormap?  I'm 
fairly new to matplotlib and have been using standard colormaps.  Below is a 
sample program that makes a color bar based on the hot colormap.  I'd like to 
have a colormap like hot, but that starts at, say, orange (near 14%), and runs 
to black (40%).



'''
Make a colorbar as a separate figure.
'''

from matplotlib import pyplot, mpl
import sys,getopt
from mpl_toolkits.basemap import Basemap, shiftgrid, cm 
#from netCDF3 import Dataset as NetCDFFile 
from mpl_toolkits.basemap import  NetCDFFile
from pylab import *

usemaprev=True

# Make a figure and axes with dimensions as desired.
fig = pyplot.figure(figsize=(8,3))
ax1 = fig.add_axes([0.05, 0.4, 0.9, 0.14])

# Set the colormap and norm to correspond to the data for which
# the colorbar will be used.
cmap = mpl.cm.cool
norm = mpl.colors.Normalize(vmin=0, vmax=40)   # here set colorbar min/max

# alter a matplotlib color table, 
# cm.jet is very useful scheme, but reversed colors are better for drought 
colordict=cm.jet._segmentdata.copy() # dictionary ('blue', 'green', 'red') of 
nested tuples

#  autumn scheme is yellow to red
colordict=cm.hot._segmentdata.copy() 

#mycolormap=cm.jet
mycolormap=cm.hot

for k in colordict.keys():
colordict[k]=[list(q) for q in colordict[k]] #convert nested tuples to 
nested list
for a in colordict[k]: 
a[0]=1.-a[0] #in inner list, change normalized value to 1 - 
value.
colordict[k].reverse() #reverse order of outer list
maprev = cm.colors.LinearSegmentedColormap("maprev",  colordict)
#map = cm.colors.LinearSegmentedColormap("map", colordict)

if usemaprev:
mycolormap=maprev
print "using reverse of defined colormap"

#ax1 = fig.add_axes([0.05, 0.65, 0.9, 0.15])
#cax = axes([0.85, 0.1, 0.05, 0.7]) # setup colorbar axes
#colorbar(format='%d') # draw colorbar

# ColorbarBase derives from ScalarMappable and puts a colorbar
# in a specified axes, so it has everything needed for a
# standalone colorbar.  There are many more kwargs, but the
# following gives a basic continuous colorbar with ticks
# and labels.
#cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=jetrev,
#   norm=norm,
#   orientation='horizontal')
cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=mycolormap,
   norm=norm,
   orientation='horizontal')
cb1.set_label('percent')

#pyplot.show()
plt.savefig('colormap.png')
 


  

--
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] defining a custom RGB colormap

2011-01-05 Thread Michael Rawlins

Paul,

Thanks for the detailed tutorial. I'm getting errors when I attempt to use 
plt.subplots(1,1) and the newcm assignment.

Traceback (most recent call last):
  File "colorbar_Mytest2.py", line 17, in 
f, ax = plt.subplots(1,1)
AttributeError: 'module' object has no attribute 'subplots'


Here are just a few of the errors I'm getting when executing colorbar command 
with newcm. Also, what does In and Out do, as in Out[68]: 0.34998 ?

plt.draw()
  File "/usr/lib/pymodules/python2.6/matplotlib/pyplot.py", line 352, in draw
get_current_fig_manager().canvas.draw()
  File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py", 
line 215, in draw
FigureCanvasAgg.draw(self)
  File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py", line 
314, in draw
self.figure.draw(self.renderer)
  File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, in 
draw_wrapper
draw(artist, renderer, *kl)
  File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 773, in draw
for a in self.axes: a.draw(renderer)
  File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, in 
draw_wrapper


Here's a simplified version that works for me:


from matplotlib import pyplot, mpl
import sys,getopt
from mpl_toolkits.basemap import Basemap, shiftgrid, cm 
#from netCDF3 import Dataset as NetCDFFile 
from mpl_toolkits.basemap import  NetCDFFile
from pylab import *

vals = norm(np.linspace(14,40,1000))
newcm = cm.colors.ListedColormap(cm.hot_r(vals))

# Make a figure and axes with dimensions as desired.
fig = pyplot.figure(figsize=(8,3))
#f, ax = plt.subplots(1,1)
ax1 = fig.add_axes([0.05, 0.4, 0.9, 0.14])
#ax2 = fig.add_axes([0.05, 0.8, 0.9, 0.6])

# Set the colormap and norm to correspond to the data for which
# the colorbar will be used.
cmap = mpl.cm.cool
norm = mpl.colors.Normalize(vmin=0, vmax=40)   # here set colorbar min/max

mycolormap=cm.hot
maprev = cm.hot_r

#f,(ax2,ax3) = plt.subplots(2,1)
cb2 = mpl.colorbar.ColorbarBase(ax1, cmap=cm.hot_r,
 norm=norm,
 orientation='horizontal')

#cb2.set_label('"percent"')
#cb3 = mpl.colorbar.ColorbarBase(ax1, cmap=newcm,
# orientation='horizontal')

#cb3.set_label("colormap interval 0.0-1.0")

plt.draw()





  

--
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
http://p.sf.net/sfu/oracle-sfdevnl
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] defining a custom RGB colormap

2011-01-06 Thread Michael Rawlins

Got it now.  Sorry about the confusion...by working for me I meant that  set of 
commands ran and made the standard colorbar.

I just installed ipython (Ubuntu OS).  Will try the interactive way as well.  
All very new.  I've used PGPLOT for ~15 years.  

Thanks again.
Mike

--- On Wed, 1/5/11, Paul Ivanov  wrote:

> From: Paul Ivanov 
> Subject: Re: [Matplotlib-users] defining a custom RGB colormap
> To: matplotlib-users@lists.sourceforge.net
> Date: Wednesday, January 5, 2011, 7:15 PM
> Michael Rawlins, on 2011-01-05
> 14:42,  wrote:
> > Thanks for the detailed tutorial. I'm getting errors
> when I
> > attempt to use plt.subplots(1,1) and the newcm
> assignment.
> > 
> > Traceback (most recent call last):
> >   File "colorbar_Mytest2.py", line 17,
> in 
> >     f, ax = plt.subplots(1,1)
> > AttributeError: 'module' object has no attribute
> 'subplots'
> 
> Ah, you must be using an older version of matplotlib -
> subplots
> is a (recently added) convenience shortcut for:
> 
>   f = plt.figure()
>   ax = plt.subplot(1,1,1)
> 
> It comes in handy when you're making lots of subplots by
> letting
> you do it with one call, instead of doing that one by one
> (as I
> have rewritten below, so you could run without having to
> upgrade
> your matplotlib.
> 
> > Also, what does In and Out do, as in Out[68]:
> 0.34999?
> 
> That's just the prompts from IPython - I *highly* recommend
> using
> IPython in place of the default python shell for
> interactive usage. 
> In[10] is what I typed,  Out[10] is the result of my
> command at
> In[10].
> 
> > Here are just a few of the errors I'm getting when
> executing
> > colorbar command with newcm. 
> 
> > Here's a simplified version that works for me:
> 
> ouch! this code doesn't do quite what you want
> 
> > from pylab import *
> 
> Try to avoid doing this - because you will get unintended
> consequences such as the one on the following line.
>  
> > vals = norm(np.linspace(14,40,1000))
> 
> This was meant to go *after* you initialize the 'norm'
> variable
> with norm = mpl.colors.Normalize(...). That's the norm I
> meant to be using. But because of the "from pylab import *"
> line,
> the norm function from numpy was imported - which is what
> was being
> used on that line as written in your code. 
> 
> so the vals=  line is equivalent to
> 
>   vals = numpy.norm(np.linspace(14,40,1000))
> 
> which meant vals got assigned the value 886.25397758173483,
> and
> not at all what we wanted. We wanted it to get an array of
> 1000
> numbers:
> 
>   vals = mpl.colors.Normalize(vmin=0,
> vmax=40)(np.linspace(14,40,1000))
> 
> That's where your trouble with newcm were coming from.
> Here's the
> complete example again, I've renamed the 'norm' variable
> to
> 'rawlins_norm' for clarity.
> 
> import matplotlib as mpl
> import matplotlib.pyplot as plt
> from matplotlib import cm 
> import numpy as np
> 
> # Make a figure and axes with dimensions as desired.
> fig = plt.figure(figsize=(8,3))
> ax1 = plt.subplot(2,1,1)
> ax2 = plt.subplot(2,1,2)
> 
> # Set the colormap and norm to correspond to the data for
> which
> # the colorbar will be used.
> rawlins_norm = mpl.colors.Normalize(vmin=0,
> vmax=40)   # here set colorbar min/max
> # the right place for vals
> vals = rawlins_norm(np.linspace(14,40,1000))
> newcm = cm.colors.ListedColormap(cm.hot_r(vals))
> 
> cb1 = mpl.colorbar.ColorbarBase(ax1, cmap=cm.hot_r,
>                
>                
>      norm=rawlins_norm,
>                
>                
>      orientation='horizontal')
> 
> cb1.set_label('"percent"')
> cb2 = mpl.colorbar.ColorbarBase(ax2, cmap=newcm,
>                
>                
>      orientation='horizontal')
> 
> cb2.set_label("colormap interval 0.0-1.0")
> plt.subplots_adjust(hspace=.7, bottom=.2)
> 
> #comment out the next line to see the original (0-40
> colormap)
> ax1.set_xlim(rawlins_norm((14,40)))
> plt.show()
> 
> 
> best,
> -- 
> Paul Ivanov
> 314 address only used for lists,  off-list direct
> email at:
> http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
> 
> -Inline Attachment Follows-
> 
> --
> Learn how Oracle Real Application Clusters (RAC) One Node
> allows customers
> to consolidate database storage, standardize their database
> environment, and, 
> should the need ari

[Matplotlib-users] m.pcolor: shade a grid based on value

2011-02-09 Thread Michael Rawlins

I'm trying to shade grids below a certain threshold a certain color. Using 
m.pcolor. Also would like to know more about how the routine I've been given, 
and am using using, (below) works. I'm fairly new to matplotlib so thanks for 
the help.

Looks like array is filled in these lines:

thevar='mean'
data=ncfile.variables[thevar]
dataa=data[:]
theshape=dataa.shape

Missing values I've chosen set here:

data.missing_value=0
try:
mval=data.missing_value
print " using specified missing value =",mval
except:
mval=1.e30
print " faking missing value=",mval
# make a masked array: using missing value(s) in mval
maskdat=ma.masked_values(slice,mval)


Map shading here, I believe:
p = m.pcolor(x,y,maskdat,shading='flat',cmap=mycolormap)

Questions. 1) How does the function know of the data array?  Then, how would I 
shade grids, with values that are less than zero, purple?

Thanks!
Mike

-

verbose=0 #verbose=2 says a bit more

import sys,getopt

from mpl_toolkits.basemap import Basemap, shiftgrid, cm 
#from netCDF3 import Dataset as NetCDFFile 
from mpl_toolkits.basemap import  NetCDFFile
from pylab import *

alloptions, otherargs= getopt.getopt(sys.argv[1:],'ro:p:X:Y:v:t:l:u:n:') # note 
the : after o and p
proj='lam'
#plotfile=None
#plotfile='testmap2.png'
usejetrev=False
colorbounds=[None,None]
extratext=""
xvar=None
yvar=None
thevar=None

#thetitle='Mean Snow Mass, January-March 1980s, HADCM3_HRM3'
#thetitle='Mean Snow Depth, January-March 1980s, CGCM3_CRCM'
#thetitle='Mean Snow Depth, January-March 2060s, CGCM3_CRCM'
#thetitle='Mean Snow Depth, January-March 1980s, CCSM_WRFG'
#thetitle='Mean Snow Depth, January-March 2060s, CCSM_WRFG'
#thetitle='Mean Snow Depth, January-March 1980s, HADCM3_HRM3'
#thetitle='Mean Snow Depth, January-March 2060s, HADCM3_HRM3'

#thetitle='Mean Snow Depth, January-March 1980s, MultiModel Mean'
thetitle='Mean Snow Depth, January-March 2060s, MultiModel Mean'

therec=None
thelev=None
cbot=None
ctop=None
startlon=-180 #default assumption for starting longitude
for theopt,thearg in alloptions:
print theopt,thearg
if theopt=='-o': # -o needs filename after it, which is now thearg
plotfile=thearg 
elif theopt=='-p': 
proj=thearg
elif theopt=='-X': 
xvar=thearg
elif theopt=='-Y': 
yvar=thearg
elif theopt=='-v': 
thevar=thearg
elif theopt=='-t': 
thetitle=thearg
elif theopt=='-l': 
cbot=thearg
elif theopt=='-u': 
ctop=thearg
elif theopt=='-n': 
therec=thearg
elif theopt=='-m': 
thelev=thearg
elif theopt=='-r': 
usejetrev=True
else: #something went wrong
print "hmm, what are these??? ", theopt, thearg
sys.exit()


print otherargs
try:
ncname=otherargs[0]
ncfile = NetCDFFile(ncname, 'r')
except:
#   ncname = raw_input("\nenter NetCDF file name =>")
#   ncfile = NetCDFFile(ncname, 'r')
ncfile = NetCDFFile('simple_xy.nc', 'r')   # Here's filename

if verbose>0:  #examine the NetCDF file
print "GLOBAL ATTRIBUTES:"
allattr=dir(ncfile)
normalattr=dir(NetCDFFile('/tmp/throwaway.nc','w'))
for item in allattr:
if item not in normalattr: print item,': ',getattr(ncfile,item)
#   for name in ncfile.ncattrs():
#   print name,'=', getattr(ncfile,name)
#   if name=='Conventions' and 
getattr(ncfile,name)=='COARDS':
#   nmcrean=True
#   startlon=0.
#   print "guessing this is an NMC reananalysis 
file"
#   else:
#   nmcrean=False
print "\n\nDIMENSIONS:"
for name in ncfile.dimensions.keys():
print "\nDIMENSION:",
try:
print name, ncfile.variables[name][:]
except:
print name, ncfile.dimensions[name]
try:
print '   ',ncfile.variables[name].units
except:
pass
try:
print '   ',ncfile.variables[name].gridtype
except:
pass
print "\n'*'\nVARIABLES:"
for name in ncfile.variables.keys():
if name in ncfile.dimensions.keys(): continue
print "\nVARIABLE:",
print name, ncfile.variables[name].dimensions,
try:
print '   ',ncfile.variables[name].units
except:
pass
try:
print "   missing 
value=",ncfile.variables[nam

[Matplotlib-users] plotting points/locations from data file

2011-04-19 Thread Michael Rawlins

I'm trying to plot a series of points/locations on a map. I'm reading the 
latitudes and longitudes from a file, with each lat, lon pair on each record 
(line).  Here is the code:

def make_float(line):
lati, longi = line.split()
return float(lati), float(longi)

my_dict = {}
with open("file.txt") as f:
for item in f:
lati,longi = make_float(item)
my_dict[lati] = longi

xpt,ypt = m(-76.1670,39.4670 )
plt.text(xpt,ypt,'1',color='white')

#print my_dict

The matplotlib code which I've previously used to plot a single point on the 
map is below, with longitude and latitude in ( ):

xpt,ypt = m(-70.758392,42.960445)
plt.text(xpt,ypt,'1',color='white')

When replacing (-70.758392,42.960445) with (longi,lati), the code plots only a 
single '1' at the location of just the last coordinate pair in the file. So now 
I only need to plot them all. Does the code I've implemented have an implicit 
loop to it? 

Mike



--
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting points/locations from data file

2011-04-19 Thread Michael Rawlins

Yes, there is whitespace between each lat and lon on each line.  But, actually, 
I'd simply like to plot a dot at each location.  The '1' was there in my 
example because I do not yet know how to plot a particular symbol.  Here is 
what I got when I tried the code you just suggested. 

Traceback (most recent call last):
  File "test.py", line 319, in 
    (lat,lon)=line.strip().split(' ')
ValueError: too many values to unpack


There are 203 records in the data file.  Line 319 of test.py is this:

(lat,lon)=line.strip().split(' ')


--- On Tue, 4/19/11, Ian Bell  wrote:

From: Ian Bell 
Subject: Re: [Matplotlib-users] plotting points/locations from data file
To: "Michael Rawlins" 
Cc: Matplotlib-users@lists.sourceforge.net
Date: Tuesday, April 19, 2011, 6:52 PM

To clarify, you are trying to read in a set of (lat,lon) points in a file that 
is space delimited, store the data, and then put a text marker at each point, 
with each point numbered in order?  The critical part is that you want to use a 
list (or numpy array) instead of a dictionary.  Something like this ought to do 
(don't have MPL on this computer though - pretty sure this should work):



lines=open('file.txt','r').readlines()
(lats,lons)=([],[])
for line in lines:
    (lat,lon)=line.strip().split(' ')
    lats.append(float(lat))
    lons.append(float(lon))



for i in range(len(lons)):
    plt.text(lats[i],lon[i],str(i+1),ha='center',va='center',color='white')

I'm sure there are a bunch of more compact ways to do this, but this should 
work.



Ian

Ian Bell
Graduate Research Assistant
Herrick Labs
Purdue University
email: ib...@purdue.edu
cell: (607)227-7626



On Tue, Apr 19, 2011 at 4:09 PM, Michael Rawlins  wrote:




I'm trying to plot a series of points/locations on a map. I'm reading the 
latitudes and longitudes from a file, with each lat, lon pair on each record 
(line).  Here is the code:



def make_float(line):

    lati, longi = line.split()

    return float(lati), float(longi)



my_dict = {}

with open("file.txt") as f:

    for item in f:

        lati,longi = make_float(item)

        my_dict[lati] = longi



xpt,ypt = m(-76.1670,39.4670 )

plt.text(xpt,ypt,'1',color='white')



#print my_dict



The matplotlib code which I've previously used to plot a single point on the 
map is below, with longitude and latitude in ( ):



xpt,ypt = m(-70.758392,42.960445)

plt.text(xpt,ypt,'1',color='white')



When replacing (-70.758392,42.960445) with (longi,lati), the code plots only a 
single '1' at the location of just the last coordinate pair in the file. So now 
I only need to plot them all. Does the code I've implemented have an implicit 
loop to it?





Mike







--

Benefiting from Server Virtualization: Beyond Initial Workload

Consolidation -- Increasing the use of server virtualization is a top

priority.Virtualization can reduce costs, simplify management, and improve

application availability and disaster protection. Learn more about boosting

the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev

___

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users



--
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting points/locations from data file

2011-04-19 Thread Michael Rawlins

Sorry I should have mentioned that longitudes are negative; there is a '-' 
before each longitude, like so:

39.4670  -76.1670 
46.4000  -74.7670 
45.3830  -75.7170 
43.6170  -79.3830 
45.5170  -73.4170 


Also the plt.text line you sent had lon[i] rather than lons[i].  I corrected 
that and changed my longitudes to not have the '-' sign and the code ran 
without error. Could the '-' be causing a problem?  I need to input the lat, 
lon as in the file as shown above.

Mike

--- On Tue, 4/19/11, Ian Bell  wrote:

From: Ian Bell 
Subject: Re: [Matplotlib-users] plotting points/locations from data file
To: "Michael Rawlins" 
Cc: Matplotlib-users@lists.sourceforge.net
Date: Tuesday, April 19, 2011, 7:22 PM

If you want to plot a given marker at the point, for instance a circle, replace 
the last line of my code plt.text.. with 

plt.plot(lats,lons,'o')

for a circle, or 

plt.plot(lats,lons,'s')



for a square.  Refer to Plot for more information on the markers you can use.  
You are getting the error because you have a delimiter different than a single 
space, so it isn't splitting the line.  Replace ' '  in the split command with 
your whitespace delimiter.  Is it a tab? Then you want '\t' .



Good luck,
Ian


Ian Bell
Graduate Research Assistant
Herrick Labs
Purdue University
email: ib...@purdue.edu
cell: (607)227-7626



On Tue, Apr 19, 2011 at 7:14 PM, Michael Rawlins  wrote:



Yes, there is whitespace between each lat and lon on each line.  But, actually, 
I'd simply like to plot a dot at each location.  The '1' was there in my 
example because I do not yet know how to plot a particular symbol.  Here is 
what I got when I tried the code you just suggested. 



Traceback (most recent call last):
  File "test.py", line 319, in 
    (lat,lon)=line.strip().split(' ')
ValueError: too many values to unpack




There are 203 records in the data file.  Line 319 of test.py is this:

(lat,lon)=line.strip().split(' ')


--- On Tue, 4/19/11, Ian Bell  wrote:



From: Ian Bell 
Subject: Re:
 [Matplotlib-users] plotting points/locations from data file
To: "Michael Rawlins" 
Cc: Matplotlib-users@lists.sourceforge.net


Date: Tuesday, April 19, 2011, 6:52 PM

To clarify, you are trying to read in a set of (lat,lon) points in a file that 
is space delimited, store the data, and then put a text marker at each point, 
with each point numbered in order?  The critical part is that you want to use a 
list (or numpy array) instead of a dictionary.  Something like this ought to do 
(don't have MPL on this computer though - pretty sure this should work):





lines=open('file.txt','r').readlines()
(lats,lons)=([],[])
for line in lines:
    (lat,lon)=line.strip().split(' ')
    lats.append(float(lat))
    lons.append(float(lon))





for i in range(len(lons)):
    plt.text(lats[i],lon[i],str(i+1),ha='center',va='center',color='white')

I'm sure there are a bunch of more compact ways to do this, but this should 
work.





Ian

Ian Bell
Graduate Research Assistant
Herrick Labs
Purdue University
email: ib...@purdue.edu


cell: (607)227-7626



On Tue, Apr 19, 2011 at 4:09 PM, Michael Rawlins  wrote:






I'm trying to plot a series of points/locations on a map. I'm reading the 
latitudes and longitudes from a file, with each lat, lon pair on each record 
(line).  Here is the code:



def make_float(line):

    lati, longi = line.split()

    return float(lati), float(longi)



my_dict = {}

with open("file.txt") as f:

    for item in f:

        lati,longi = make_float(item)

        my_dict[lati] = longi



xpt,ypt = m(-76.1670,39.4670 )

plt.text(xpt,ypt,'1',color='white')



#print my_dict



The matplotlib code which I've previously used to plot a single point on the 
map is below, with longitude and latitude in ( ):



xpt,ypt = m(-70.758392,42.960445)

plt.text(xpt,ypt,'1',color='white')



When replacing (-70.758392,42.960445) with (longi,lati), the code plots only a 
single '1' at the location of just the last coordinate pair in the file. So now 
I only need to plot them all. Does the code I've implemented have an implicit 
loop to it?







Mike







--

Benefiting from Server Virtualization: Beyond Initial Workload

Consolidation -- Increasing the use of server virtualization is a top

priority.Virtualization can reduce costs, simplify management, and improve

application availability and disaster protection. Learn more about boosting

the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev

___

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists

Re: [Matplotlib-users] plotting points/locations from data file

2011-04-19 Thread Michael Rawlins

I've set up the data file with comma delimiter and one space.  Split command 
now:

(lat,lon)=line.strip().split(',')

Code runs without error but no points on the map.  These two lines, however, do 
produce an asterisk at the proper location:

xpt,ypt = m(-75.0,43.0)
text(xpt,ypt,'*') 

I will strip the code down to bare minimum (take out reading of netCDF data 
file) and paste it here along with ten example lats,lons.

--- On Tue, 4/19/11, Ian Bell  wrote:

From: Ian Bell 
Subject: Re: [Matplotlib-users] plotting points/locations from data file
To: "Michael Rawlins" 
Cc: Matplotlib-users@lists.sourceforge.net
Date: Tuesday, April 19, 2011, 7:32 PM

The easiest solution would be to put a comma as the delimiter between the lat 
and lon, and then change split(' ') to split(',').  Then everything should work 
fine.  I exclusively work with comma separated files for this exact reason.  
You are right that I had a typo, it should be lons[i].  It looks like you have 
two spaces as the delimiter currently based on your copy-paste.  That's why 
split doesn't give you two values.  In general I recommend that you avoid two 
spaces as the delimiter, just going to cause problems.



Ian Bell
Graduate Research Assistant
Herrick Labs
Purdue University
email: ib...@purdue.edu
cell: (607)227-7626



On Tue, Apr 19, 2011 at 7:26 PM, Michael Rawlins  wrote:



Sorry I should have mentioned that longitudes are negative; there is a '-' 
before each longitude, like so:



39.4670  -76.1670 
46.4000  -74.7670 
45.3830  -75.7170 
43.6170  -79.3830 
45.5170  -73.4170 


Also the plt.text line you sent had lon[i] rather than lons[i].  I corrected 
that and changed my longitudes to not have the '-' sign and the code ran 
without error. Could the '-' be causing a problem?  I need to input the lat, 
lon as in the file as shown above.



Mike

--- On Tue, 4/19/11, Ian Bell  wrote:



From: Ian Bell 
Subject: Re: [Matplotlib-users] plotting points/locations from data file
To: "Michael Rawlins"
 
Cc: Matplotlib-users@lists.sourceforge.net
Date: Tuesday, April 19, 2011, 7:22 PM



If you want to plot a given marker at the point, for instance a circle, replace 
the last line of my code plt.text.. with 

plt.plot(lats,lons,'o')

for a circle, or 



plt.plot(lats,lons,'s')



for a square.  Refer to Plot for more information on the markers you can use.  
You are getting the error because you have a delimiter different than a single 
space, so it isn't splitting the line.  Replace ' '  in the split command with 
your whitespace delimiter.  Is it a tab? Then you want '\t' .





Good luck,
Ian


Ian Bell
Graduate Research Assistant
Herrick Labs
Purdue University
email: ib...@purdue.edu


cell: (607)227-7626



On Tue, Apr 19, 2011 at 7:14 PM, Michael Rawlins  wrote:





Yes, there is whitespace between each lat and lon on each line.  But, actually, 
I'd simply like to plot a dot at each location.  The '1' was there in my 
example because I do not yet know how to plot a particular symbol.  Here is 
what I got when I tried the code you just suggested. 





Traceback (most recent call last):
  File "test.py", line 319, in 
    (lat,lon)=line.strip().split(' ')
ValueError: too many values to unpack




There are 203 records in the data file.  Line 319 of test.py is this:

(lat,lon)=line.strip().split(' ')


--- On Tue, 4/19/11, Ian Bell  wrote:





From: Ian Bell 


Subject: Re:
 [Matplotlib-users] plotting points/locations from data file
To: "Michael Rawlins" 
Cc: Matplotlib-users@lists.sourceforge.net




Date: Tuesday, April 19, 2011, 6:52 PM

To clarify, you are trying to read in a set of (lat,lon) points in a file that 
is space delimited, store the data, and then put a text marker at each point, 
with each point numbered in order?  The critical part is that you want to use a 
list (or numpy array) instead of a dictionary.  Something like this ought to do 
(don't have MPL on this computer though - pretty sure this should work):







lines=open('file.txt','r').readlines()
(lats,lons)=([],[])
for line in lines:
    (lat,lon)=line.strip().split(' ')
    lats.append(float(lat))
    lons.append(float(lon))







for i in range(len(lons)):
    plt.text(lats[i],lon[i],str(i+1),ha='center',va='center',color='white')

I'm sure there are a bunch of more compact ways to do this, but this should 
work.







Ian

Ian Bell
Graduate Research Assistant
Herrick Labs
Purdue University
email: ib...@purdue.edu




cell: (607)227-7626



On Tue, Apr 19, 2011 at 4:09 PM, Michael Rawlins  wrote:








I'm trying to plot a series of points/locations on a map. I'm reading the 
latitudes and longitudes from a file, with each lat, lon pair on each record 
(li

Re: [Matplotlib-users] plotting points/locations from data file

2011-04-19 Thread Michael Rawlins

Do I need to add something to the header(?) at top of file to use csv2rec?   

import sys,getopt

from mpl_toolkits.basemap import Basemap, shiftgrid, cm 
from mpl_toolkits.basemap import  NetCDFFile
from pylab import *



--- On Tue, 4/19/11, Ian Bell  wrote:

From: Ian Bell 
Subject: Re: [Matplotlib-users] plotting points/locations from data file
To: "G Jones" 
Cc: "Michael Rawlins" , 
Matplotlib-users@lists.sourceforge.net
Date: Tuesday, April 19, 2011, 7:35 PM

Have to say I whole-heartedly agree with Glenn.  One problem I have run into is 
a funky file headers where I want to skip lines 1,2,3, and 4, but line 3 is my 
real header line which doesn't work so well with either of the below 
solutions.  I had to write my own wrapper to deal with these weird types of 
files.



Ian
  

Ian Bell
Graduate Research Assistant
Herrick Labs
Purdue University
email: ib...@purdue.edu
cell: (607)227-7626



On Tue, Apr 19, 2011 at 7:32 PM, G Jones  wrote:


You may find it easier to use mlab.csv2rec or numpy.loadtxt. 

e.g. 

data = csv2rec(filename,delimiter=' ')
plot(data[:,0],data[:,1],'o')




On Tue, Apr 19, 2011 at 4:26 PM, Michael Rawlins  wrote:





Sorry I should have mentioned that longitudes are negative; there is a '-' 
before each longitude, like so:

39.4670  -76.1670 
46.4000  -74.7670 
45.3830  -75.7170 
43.6170  -79.3830 
45.5170  -73.4170 





Also the plt.text line you sent had lon[i] rather than lons[i].  I corrected 
that and changed my longitudes to not have the '-' sign and the code ran 
without error. Could the '-' be causing a problem?  I need to input the lat, 
lon as in the file as shown above.




Mike

--- On Tue, 4/19/11, Ian Bell  wrote:




From: Ian Bell 
Subject: Re: [Matplotlib-users] plotting points/locations from data file
To: "Michael Rawlins"
 
Cc: Matplotlib-users@lists.sourceforge.net
Date: Tuesday, April 19, 2011, 7:22 PM




If you want to plot a given marker at the point, for instance a circle, replace 
the last line of my code plt.text.. with 

plt.plot(lats,lons,'o')

for a circle, or 




plt.plot(lats,lons,'s')



for a square.  Refer to Plot for more information on the markers you can use.  
You are getting the error because you have a delimiter different than a single 
space, so it isn't splitting the line.  Replace ' '  in the split command with 
your whitespace delimiter.  Is it a tab? Then you want '\t' .






Good luck,
Ian


Ian Bell
Graduate Research Assistant
Herrick Labs
Purdue University
email: ib...@purdue.edu



cell: (607)227-7626



On Tue, Apr 19, 2011 at 7:14 PM, Michael Rawlins  wrote:






Yes, there is whitespace between each lat and lon on each line.  But, actually, 
I'd simply like to plot a dot at each location.  The '1' was there in my 
example because I do not yet know how to plot a particular symbol.  Here is 
what I got when I tried the code you just suggested. 






Traceback (most recent call last):
  File "test.py", line 319, in 
    (lat,lon)=line.strip().split(' ')
ValueError: too many values to unpack




There are 203 records in the data file.  Line 319 of test.py is this:

(lat,lon)=line.strip().split(' ')


--- On Tue, 4/19/11, Ian Bell  wrote:






From: Ian Bell 



Subject: Re:
 [Matplotlib-users] plotting points/locations from data file
To: "Michael Rawlins" 
Cc: Matplotlib-users@lists.sourceforge.net





Date: Tuesday, April 19, 2011, 6:52 PM

To clarify, you are trying to read in a set of (lat,lon) points in a file that 
is space delimited, store the data, and then put a text marker at each point, 
with each point numbered in order?  The critical part is that you want to use a 
list (or numpy array) instead of a dictionary.  Something like this ought to do 
(don't have MPL on this computer though - pretty sure this should work):








lines=open('file.txt','r').readlines()
(lats,lons)=([],[])
for line in lines:
    (lat,lon)=line.strip().split(' ')
    lats.append(float(lat))
    lons.append(float(lon))








for i in range(len(lons)):
    plt.text(lats[i],lon[i],str(i+1),ha='center',va='center',color='white')

I'm sure there are a bunch of more compact ways to do this, but this should 
work.








Ian

Ian Bell
Graduate Research Assistant
Herrick Labs
Purdue University
email: ib...@purdue.edu





cell: (607)227-7626



On Tue, Apr 19, 2011 at 4:09 PM, Michael Rawlins  wrote:









I'm trying to plot a series of points/locations on a map. I'm reading the 
latitudes and longitudes from a file, with each lat, lon pair on each record 
(line).  Here is the code:



def make_float(line):

    lati, longi = line.split()

    return float(lati), float(longi)



my_dict = {}

with open("file.txt") as f:

    for item in f:

     

Re: [Matplotlib-users] plotting points/locations from data file

2011-04-19 Thread Michael Rawlins
t(lons,lats,'*')

#data = csv2rec('file2.txt',delimiter=',')
#plot(data[:,0],data[:,1],'o')

#data = csv2rec('file2.txt',delimiter=' ',names=['lat','lon'])
#plot(data['lat'],data['lon'],'o')

data = np.loadtxt('file2.txt')
plot(data[:,0],data[:,1],'o')

xpt,ypt = m(-75.0,43.0)
text(xpt,ypt,'*')


# draw coastlines and political boundaries.
m.drawcoastlines()
m.drawcountries()
m.drawstates()
# draw parallels and meridians.
# label on left, right and bottom of map.
m.drawparallels(parallels,labels=[1,0,0,0])
m.drawmeridians(meridians,labels=[1,1,0,1])
    
#if plotfile:
#    savefig(plotfile, dpi=72, facecolor='w', bbox_inches='tight', 
edgecolor='w', orientation='portrait')
#else:
#    show()

#plt.savefig('map.png')
plt.savefig('map.eps')
#  comment show to mass produce




--- On Tue, 4/19/11, G Jones  wrote:

From: G Jones 
Subject: Re: [Matplotlib-users] plotting points/locations from data file
To: "Michael Rawlins" 
Cc: "Ian Bell" , Matplotlib-users@lists.sourceforge.net
Date: Tuesday, April 19, 2011, 8:12 PM

No need for a header, but I guess my example was a little too simple. You could 
do:
data = csv2rec(filename,delimiter=' ',names=['lat','lon'])
plot(data['lat'],data['lon'],'o')


or you could do
data = np.loadtxt(filename)
plot(data[:,0],data[:,1],'o')

In general, I strongly recommend developing with ipython --pylab. That way all 
the documentation is at your fingertips using the ? and ?? notation.



--
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting points/locations from data file

2011-04-19 Thread Michael Rawlins

On second thought, the code requires basemap package too.
Mike  

--- On Tue, 4/19/11, Michael Rawlins  wrote:

From: Michael Rawlins 
Subject: Re: [Matplotlib-users] plotting points/locations from data file
To: "G Jones" 
Cc: Matplotlib-users@lists.sourceforge.net
Date: Tuesday, April 19, 2011, 8:26 PM


The first example produced no plotted symbols but no errors on execution.  The 
second example produced this:

Plotting, please wait...maybe more than 10 seconds
Traceback (most recent call last):
  File "testNew.py", line 137, in 
    data = np.loadtxt('file2.txt')
  File "/usr/lib/python2.6/dist-packages/numpy/lib/io.py", line 489, in loadtxt
    X.append(tuple([conv(val) for (conv, val) in zip(converters, vals)]))
ValueError: invalid literal for float(): 39.4670,
  

G..  

My code follows.  I believe this is standard python and matplotlib.  Should 
produce a map of Northeast US.  Perhaps someone could get this working with a 
few example points:

39.4670, -76.1670
46.4000, -74.7670
45.3830, -75.7170
43.6170,
 -79.3830
45.5170, -73.4170
45.6170, -74.4170
43.8330, -77.1500
43.9500, -78.1670
43.2500, -79.2170
43.8330, -66.0830


#!/usr/bin/env python
# v0.5 19 June 2010
# General purpose plotter of 2-D gridded data from NetCDF files,
# plotted with map boundaries.
# NetCDF file should have data in either 2-D, 3-D or 4-D arrays.
# Works with the netCDF files in the tutorial, and also the
# files available for download at:
# http://www.cdc.noaa.gov/cdc/data.ncep.reanalysis.html 
# Adapted from the basemap example plotmap_pcolor.py,
# Some of the variable names from that example are retained.
#
# Uses basemap's pcolor function.  Pcolor accepts arrays
# of the longitude and latitude  points of the vertices on the pixels,
# as well as an array with the numerical value in the pixel. 

verbose=0 #verbose=2 says a bit more

import sys,getopt

from mpl_toolkits.basemap import
 Basemap, shiftgrid, cm 
#from netCDF3 import Dataset as NetCDFFile 
from mpl_toolkits.basemap import  NetCDFFile
from pylab import *
#from matplotlib.mlab import csv2rec

alloptions, otherargs= getopt.getopt(sys.argv[1:],'ro:p:X:Y:v:t:l:u:n:') # note 
the : after o and p
proj='lam'
#plotfile=None
#plotfile='testmap2.png'
usejetrev=False
colorbounds=[None,None]
extratext=""
xvar=None
yvar=None
thevar=None

therec=None
thelev=None
cbot=None
ctop=None
startlon=-180 #default assumption for starting longitude
for theopt,thearg in alloptions:
    print theopt,thearg
    if theopt=='-o': # -o needs filename after it, which is now thearg
        plotfile=thearg    
    elif theopt=='-p': 
        proj=thearg
    elif theopt=='-X':
 
        xvar=thearg
    elif theopt=='-Y': 
        yvar=thearg
    elif theopt=='-v': 
        thevar=thearg
    elif theopt=='-t': 
        thetitle=thearg
    elif theopt=='-l': 
        cbot=thearg
    elif theopt=='-u': 
        ctop=thearg
    elif theopt=='-n': 
        therec=thearg
    elif theopt=='-m': 
        thelev=thearg
    elif theopt=='-r': 
        usejetrev=True
    else: #something went wrong
        print "hmm, what are these??? ", theopt,
 thearg
        sys.exit()

print "\nPlotting, please wait...maybe more than 10 seconds"
if proj=='lam': #Lambert Conformal
    m = Basemap(llcrnrlon=-80.6,llcrnrlat=38.4,urcrnrlon=-66.0,urcrnrlat=47.7,\
    resolution='l',area_thresh=1000.,projection='lcc',\
    lat_1=65.,lon_0=-73.3)
    xtxt=20. #offset for text
    ytxt=20.
    parallels = arange(38.,48.,4.)
    meridians = arange(-80.,-68.,4.)
else: #cylindrical is default
#    m = Basemap(llcrnrlon=-180.,llcrnrlat=-90,urcrnrlon=180.,urcrnrlat=90.,\
#    resolution='c',area_thresh=1.,projection='cyl')
    m =
 
Basemap(llcrnrlon=startlon,llcrnrlat=-90,urcrnrlon=startlon+360.,urcrnrlat=90.,\
    resolution='c',area_thresh=1.,projection='cyl')
    xtxt=1.
    ytxt=0.
    parallels = arange(-90.,90.,30.)
    if startlon==-180:
        meridians = arange(-180.,180.,60.)
    else:
        meridians = arange(0.,360.,60.)

if verbose>1: print m.__doc__ 
xsize = rcParams['figure.figsize'][0]
fig=figure(figsize=(xsize,m.aspect*xsize))
#ax = fig.add_axes([0.08,0.1,0.7,0.7],axisbg='white')
ax = fig.add_axes([0.06,0.00,0.8,1.0],axisbg='white')
# make a pcolor plot.
#x, y = m(lons, lats)
#p = m.pcolor(x,y,maskdat,shading='flat',cmap=cmap)
#clim(*colorbounds)

# axes units units are left, bottom, width,
 height
#cax = axes([0.85, 0.1, 0.05, 0.7])  #  colorbar axes for map w/ no graticule
cax = axes([0.88, 0.1, 0.06, 0.81])  #  colorbar axes for map w/ graticule

axes(ax)  # make the original axes current again

#    Plot symbol at st

Re: [Matplotlib-users] plotting points/locations from data file

2011-04-19 Thread Michael Rawlins

Thanks Glenn and Ian.  I have just explicitly set delimiter=',' but still no 
points plotted.  I'm new to this software so will look into using ipython 
--pylab and documentation.  For the short term I will just create in a shell 
script 200 strings/records with the lat,lon inserted in the plot command and 
paste them into the source code.  Not ideal but will get the job done.

Mike 

--- On Tue, 4/19/11, G Jones  wrote:

From: G Jones 
Subject: Re: [Matplotlib-users] plotting points/locations from data file
To: "Michael Rawlins" 
Cc: "Ian Bell" , Matplotlib-users@lists.sourceforge.net
Date: Tuesday, April 19, 2011, 8:31 PM

As you can see from the error message, it's trying to convert "39.4670," to a 
float and complaining that this is not a valid value (because of the comma. The 
examples I suggested were for your original space delimited data. For comma 
delimited data you'll want to remove the delimiter argument to csv2rec (or 
explicitly set delimiter=',' if you prefer). If you want to use loadtxt, you 
can set delimiter=','

Again, read the doc strings to see what these functions are expecting by 
default.


On Tue, Apr 19, 2011 at 5:26 PM, Michael Rawlins  wrote:



The first example produced no plotted symbols but no errors on execution.  The 
second example produced this:

Plotting, please wait...maybe more than 10 seconds
Traceback (most recent call last):

  File "testNew.py", line 137, in 
    data = np.loadtxt('file2.txt')
  File "/usr/lib/python2.6/dist-packages/numpy/lib/io.py", line 489, in loadtxt
    X.append(tuple([conv(val) for (conv, val) in zip(converters, vals)]))

ValueError: invalid literal for float(): 39.4670,
  

G..  

My code follows.  I believe this is standard python and matplotlib.  Should 
produce a map of Northeast US.  Perhaps someone could get this working with a 
few example points:


39.4670, -76.1670
46.4000, -74.7670
45.3830, -75.7170
43.6170,
 -79.3830
45.5170, -73.4170
45.6170, -74.4170
43.8330, -77.1500
43.9500, -78.1670
43.2500, -79.2170
43.8330, -66.0830


#!/usr/bin/env python
# v0.5 19 June 2010
# General purpose plotter of 2-D gridded data from NetCDF files,

# plotted with map boundaries.
# NetCDF file should have data in either 2-D, 3-D or 4-D arrays.
# Works with the netCDF files in the tutorial, and also the
# files available for download at:
# http://www.cdc.noaa.gov/cdc/data.ncep.reanalysis.html 

# Adapted from the basemap example plotmap_pcolor.py,
# Some of the variable names from that example are retained.
#
# Uses basemap's pcolor function.  Pcolor accepts arrays
# of the longitude and latitude  points of the vertices on the pixels,

# as well as an array with the numerical value in the pixel. 

verbose=0 #verbose=2 says a bit more

import sys,getopt

from mpl_toolkits.basemap import
 Basemap, shiftgrid, cm 
#from netCDF3 import Dataset as NetCDFFile 
from mpl_toolkits.basemap import  NetCDFFile
from pylab import *
#from matplotlib.mlab import csv2rec

alloptions, otherargs= getopt.getopt(sys.argv[1:],'ro:p:X:Y:v:t:l:u:n:') # note 
the : after o and p

proj='lam'
#plotfile=None
#plotfile='testmap2.png'
usejetrev=False
colorbounds=[None,None]
extratext=""
xvar=None
yvar=None
thevar=None

therec=None
thelev=None

cbot=None
ctop=None
startlon=-180 #default assumption for starting longitude
for theopt,thearg in alloptions:
    print theopt,thearg
    if theopt=='-o': # -o needs filename after it, which is now thearg

        plotfile=thearg    
    elif theopt=='-p': 
        proj=thearg
    elif theopt=='-X':
 
        xvar=thearg
    elif theopt=='-Y': 
        yvar=thearg
    elif theopt=='-v': 
        thevar=thearg
    elif theopt=='-t': 
        thetitle=thearg
    elif theopt=='-l': 

        cbot=thearg
    elif theopt=='-u': 
        ctop=thearg
    elif theopt=='-n': 
        therec=thearg
    elif theopt=='-m': 
        thelev=thearg
    elif theopt=='-r': 

        usejetrev=True
    else: #something went wrong
        print "hmm, what are these??? ", theopt,
 thearg
        sys.exit()

print "\nPlotting, please wait...maybe more than 10 seconds"
if proj=='lam': #Lambert Conformal
    m = Basemap(llcrnrlon=-80.6,llcrnrlat=38.4,urcrnrlon=-66.0,urcrnrlat=47.7,\

    resolution='l',area_thresh=1000.,projection='lcc',\
    lat_1=65.,lon_0=-73.3)
    xtxt=20. #offset for text
    ytxt=20.
    parallels = arange(38.,48.,4.)
    meridians = arange(-80.,-68.,4.)

else: #cylindrical is default
#    m = Basemap(llcrnrlon=-180.,llcrnrlat=-90,urcrnrlon=180.,urcrnrlat=90.,\
#    resolution='c',area_thresh=1.,projection='cyl')
    m =
 
Basemap(llcrnrlon=startlon,llcrnrlat=-90,

Re: [Matplotlib-users] plotting points/locations from data file

2011-04-20 Thread Michael Rawlins

These commands plot points on a map in my code using python, matplotlib, and 
basemap.  Thanks to Ian and Glenn for their assistance.  Turns out lat, lon 
needed to be transformed into Lambert's coordinate space upon which the rest of 
the map is based. If anyone knows of a more elegant way to work on the entire 
array, rather than each point, I'll give it a shot.   

Mike

data = csv2rec('file2.txt',delimiter=',',names=['lat','lon'])
for i in range(len(data)):
    x,y=m(data['lon'][i],data['lat'][i])  # Translate to basemap's (Lambert) 
coordinate space
    plot(x,y,color='black',marker='.',markersize=6.0)

--
Benefiting from Server Virtualization: Beyond Initial Workload 
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve 
application availability and disaster protection. Learn more about boosting 
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users