Re: [Matplotlib-users] Heat Map

2010-04-02 Thread Marius 't Hart
rachel-mikel_arcejae...@hmc.edu wrote:
 Hello,

 I'm trying to create a heat map from two lists of corresponding X and Y 
 coordinates.

 I've tried both numpy.histogram2d() and pyplot.hexbin().

 The histogram I get back doesn't correspond to the points I gave it. It seems 
 as if it's sorting each X and Y list and then eliminating some points, which 
 would definitely not give me the coordinates I want. (Also, I want to be able 
 to switch the origin to the upper-left corner, but I can't figure out how to 
 do this with imshow().)
   
Histogram2d works fine for me, I use it more or less the same way you 
do, so I can't help there.
You can specify the origin in imshow by saying:

plt.imshow(heatmap, extent=axesExtent, origin='upper')

 The hexbin graph does correspond to my original points,  but rather than 
 having hexagons of equal size, some are super thin and tiny. (I'd also like 
 to fill in the entire graph with background color (I want the axes to extend 
 beyond the data) - is there a way to do that?) 
   
You can specify the bins in histogram2d to cover the whole screen (you 
can also specify bins in hexbin, which should be similar):

xedges, yedges = linspace(0,1400,(1400/50)+1), linspace(0,600,(600/50)+1)
npy.histogram2d(xList, yList, bins=[xedges,yedges])


 Here's the code I wrote for the histogram and hexbin. Am I doing something 
 wrong? I've attached three graphs - one is my coordinates as a scatter plot, 
 one my histogram result, and the other the hexbin result.

 Thanks!
 ~Rachel

 def plotHistogram( coordsTuple ):
 
 plt.clf()   # Clears any previous figure
 
 xList = coordsTuple[0]
 yList = coordsTuple[1]

 heatmap, xedges, yedges = npy.histogram2d(xList, yList)
 axesExtent = [0, xedges[-1], 0, yedges[-1]]
 plt.imshow(heatmap, extent = axesExtent)

 plt.title( Heat Map of User Clicks )

 name = raw_input(\nImage name and extension: )
 plt.savefig(name)


 def plotHexbins( coordsTuple ):
 
 plt.clf()   # Clears any previous figure
 
 xList = coordsTuple[0]
 yList = coordsTuple[1]

 plt.hexbin(xList, yList)

 plt.title( Heat Map of User Clicks )

 name = raw_input(\nImage name and extension: )
 plt.savefig(name)

   


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Basemap/ orthographic projection plot doesn't respect globe boundary

2010-04-02 Thread Will Hewson

Hi forum/ mailing list,

When I plot in the orthographic projection I'm getting the large artefact
shown below extending away from the north east of the globe.

I'm not finding the same problem when plotting in a full globe projection so
I'm presuming the problem is with the way I'm projecting everything rather
than my data itself.

I've included my plotting code below, if anyone is able to spot some glaring
omissions/ errors I'd be most grateful (I've been using python/ matplotlib
for only a couple of weeks now!).


http://old.nabble.com/file/p28117655/binploterr.png 


#!/usr/local/bin/python2.6

import numpy as np

import matplotlib.pyplot as plt

from mpl_toolkits.basemap import Basemap

import sys, glob


#input must be 3 col file of lons lats and data

#bins input values into half degree grid, ignores negative values


plts = glob.glob('*.plt')

x = np.arange(-180, 180, 0.5); y = np.arange(-90, 90, 0.5)

grid_lon, grid_lat = np.meshgrid(x,y) #regularly spaced 2D grid

n_vals = np.zeros((360,720)) #mean divisor

dat = np.zeros((360,720)) #2D grid of zeros 


for pt in plts:



in_file = pt

data = np.loadtxt(in_file, comments = ';')

fname = in_file.split('.')[0]


lon = data[:,0] #original 1D list

lat = data[:,1] #original 1D list

slcol = data[:,2] #z data


lon = (np.around(lon*2))/2 #round to nearest .0 or 0.5

lat = (np.around(lat*2))/2 #round to nearest .0 or 0.5


##keep the below between files


j=0


for i in slcol:

if lon[j]  0:

grid_lon_ind = 360+(lon[j]*2)

grid_lat_ind = 180+(lat[j]*2)

else:

grid_lon_ind = 360-(lon[j]*2)

grid_lat_ind = 180+(lat[j]*2)



if i  0:

dat[grid_lat_ind, grid_lon_ind] += i #add i'th value

n_vals[grid_lat_ind, grid_lon_ind] += 1 #increase cell counter
by 1 for each extra value

j+=1


dat = np.nan_to_num(dat/n_vals)


#create map object

fig = plt.figure()

m = Basemap(projection='ortho', lon_0=lon[(len(lon)/2)], lat_0=0,
resolution='l', area_thresh=1.)

#m = Basemap(projection='moll',lon_0=0,resolution='c', area_thresh=1.)


X,Y = m(grid_lon, grid_lat)


#pass all 2d arrays to pcolor

im = m.pcolormesh(X,Y,dat)


#add coastlines, globe boundary and colourbar

m.drawcoastlines()

m.drawmapboundary()

m.drawparallels(np.arange(-90, 90,30))

m.drawmeridians(np.arange(-180,180,30))


fig.colorbar(im)

plt.title('CH20 and ting')

plt.savefig('binplot.png')



Thanks for your help,


Will.
-- 
View this message in context: 
http://old.nabble.com/Basemap--orthographic-projection-plot-doesn%27t-respect-globe-boundary-tp28117655p28117655.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Basemap/ orthographic projection plot doesn't respect globe boundary

2010-04-02 Thread Will Hewson

Hi forum/ mailing list,

When I plot in the orthographic projection I'm getting the large artefact
shown below extending away from the north east of the globe.

I'm not finding the same problem when plotting in a full globe projection so
I'm presuming the problem is with the way I'm projecting everything rather
than my data itself.

I've included my plotting code below, if anyone is able to spot some glaring
omissions/ errors I'd be most grateful (I've been using python/ matplotlib
for only a couple of weeks now!).


http://old.nabble.com/file/p28117654/binploterr.png 


#!/usr/local/bin/python2.6

import numpy as np

import matplotlib.pyplot as plt

from mpl_toolkits.basemap import Basemap

import sys, glob


#input must be 3 col file of lons lats and data

#bins input values into half degree grid, ignores negative values


plts = glob.glob('*.plt')

x = np.arange(-180, 180, 0.5); y = np.arange(-90, 90, 0.5)

grid_lon, grid_lat = np.meshgrid(x,y) #regularly spaced 2D grid

n_vals = np.zeros((360,720)) #mean divisor

dat = np.zeros((360,720)) #2D grid of zeros 


for pt in plts:



in_file = pt

data = np.loadtxt(in_file, comments = ';')

fname = in_file.split('.')[0]


lon = data[:,0] #original 1D list

lat = data[:,1] #original 1D list

slcol = data[:,2] #z data


lon = (np.around(lon*2))/2 #round to nearest .0 or 0.5

lat = (np.around(lat*2))/2 #round to nearest .0 or 0.5


##keep the below between files


j=0


for i in slcol:

if lon[j]  0:

grid_lon_ind = 360+(lon[j]*2)

grid_lat_ind = 180+(lat[j]*2)

else:

grid_lon_ind = 360-(lon[j]*2)

grid_lat_ind = 180+(lat[j]*2)



if i  0:

dat[grid_lat_ind, grid_lon_ind] += i #add i'th value

n_vals[grid_lat_ind, grid_lon_ind] += 1 #increase cell counter
by 1 for each extra value

j+=1


dat = np.nan_to_num(dat/n_vals)


#create map object

fig = plt.figure()

m = Basemap(projection='ortho', lon_0=lon[(len(lon)/2)], lat_0=0,
resolution='l', area_thresh=1.)

#m = Basemap(projection='moll',lon_0=0,resolution='c', area_thresh=1.)


X,Y = m(grid_lon, grid_lat)


#pass all 2d arrays to pcolor

im = m.pcolormesh(X,Y,dat)


#add coastlines, globe boundary and colourbar

m.drawcoastlines()

m.drawmapboundary()

m.drawparallels(np.arange(-90, 90,30))

m.drawmeridians(np.arange(-180,180,30))


fig.colorbar(im)

plt.title('CH20 and ting')

plt.savefig('binplot.png')



Thanks for your help,


Will.
-- 
View this message in context: 
http://old.nabble.com/Basemap--orthographic-projection-plot-doesn%27t-respect-globe-boundary-tp28117654p28117654.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap/ orthographic projection plot doesn't respect globe boundary

2010-04-02 Thread Jeff Whitaker

On 4/2/10 4:27 AM, Will Hewson wrote:
Hi forum/ mailing list, When I plot in the orthographic projection I'm 
getting the large artefact shown below extending away from the north 
east of the globe. I'm not finding the same problem when plotting in a 
full globe projection so I'm presuming the problem is with the way I'm 
projecting everything rather than my data itself. I've included my 
plotting code below, if anyone is able to spot some glaring omissions/ 
errors I'd be most grateful (I've been using python/ matplotlib for 
only a couple of weeks now!).




Will:   You'll have to provide the data so we can actually run the script.

-Jeff

#!/usr/local/bin/python2.6
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import sys, glob

#input must be 3 col file of lons lats and data
#bins input values into half degree grid, ignores negative values

plts = glob.glob('*.plt')
x = np.arange(-180, 180, 0.5); y = np.arange(-90, 90, 0.5)
grid_lon, grid_lat = np.meshgrid(x,y) #regularly spaced 2D grid
n_vals = np.zeros((360,720)) #mean divisor
dat = np.zeros((360,720)) #2D grid of zeros

for pt in plts:

in_file = pt
data = np.loadtxt(in_file, comments = ';')
fname = in_file.split('.')[0]

lon = data[:,0] #original 1D list
lat = data[:,1] #original 1D list
slcol = data[:,2] #z data

lon = (np.around(lon*2))/2 #round to nearest .0 or 0.5
lat = (np.around(lat*2))/2 #round to nearest .0 or 0.5

##keep the below between files

j=0

for i in slcol:
if lon[j]  0:
grid_lon_ind = 360+(lon[j]*2)
grid_lat_ind = 180+(lat[j]*2)
else:
grid_lon_ind = 360-(lon[j]*2)
grid_lat_ind = 180+(lat[j]*2)

if i  0:
dat[grid_lat_ind, grid_lon_ind] += i #add i'th value
n_vals[grid_lat_ind, grid_lon_ind] += 1 #increase cell counter by 1 
for each extra value

j+=1

dat = np.nan_to_num(dat/n_vals)

#create map object
fig = plt.figure()
m = Basemap(projection='ortho', lon_0=lon[(len(lon)/2)], lat_0=0, 
resolution='l', area_thresh=1.)

#m = Basemap(projection='moll',lon_0=0,resolution='c', area_thresh=1.)

X,Y = m(grid_lon, grid_lat)

#pass all 2d arrays to pcolor
im = m.pcolormesh(X,Y,dat)

#add coastlines, globe boundary and colourbar
m.drawcoastlines()
m.drawmapboundary()
m.drawparallels(np.arange(-90, 90,30))
m.drawmeridians(np.arange(-180,180,30))

fig.colorbar(im)
plt.title('CH20 and ting')
plt.savefig('binplot.png')

Thanks for your help,
Will.

View this message in context: Basemap/ orthographic projection plot 
doesn't respect globe boundary 
http://old.nabble.com/Basemap--orthographic-projection-plot-doesn%27t-respect-globe-boundary-tp28117654p28117654.html
Sent from the matplotlib - users mailing list archive 
http://old.nabble.com/matplotlib---users-f2906.html at Nabble.com.



--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev


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


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap/ orthographic projection plot doesn't respect globe boundary

2010-04-02 Thread Jeff Whitaker

On 4/2/10 4:27 AM, Will Hewson wrote:
Hi forum/ mailing list, When I plot in the orthographic projection I'm 
getting the large artefact shown below extending away from the north 
east of the globe. I'm not finding the same problem when plotting in a 
full globe projection so I'm presuming the problem is with the way I'm 
projecting everything rather than my data itself. I've included my 
plotting code below, if anyone is able to spot some glaring omissions/ 
errors I'd be most grateful (I've been using python/ matplotlib for 
only a couple of weeks now!).
Will:  I think what's happening is that pcolormesh is having trouble 
dealing with the higher curvlinear grid, which becomes nearly 
pathological near the horizon of the projection.  If you take a look at 
the test.py file in the basemap examples directory, you'll see an 
example orthographic plot that solves this problem by first 
interpolating the data to a regular grid in projection coordinates (with 
values over the plot horizon masked).  The example uses imshow, but 
pcolormesh works as well.  A standalone version of the example using 
pcolormesah  is attached, which uses data files in the basemap examples 
directory.


-Jeff


#!/usr/local/bin/python2.6
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import sys, glob

#input must be 3 col file of lons lats and data
#bins input values into half degree grid, ignores negative values

plts = glob.glob('*.plt')
x = np.arange(-180, 180, 0.5); y = np.arange(-90, 90, 0.5)
grid_lon, grid_lat = np.meshgrid(x,y) #regularly spaced 2D grid
n_vals = np.zeros((360,720)) #mean divisor
dat = np.zeros((360,720)) #2D grid of zeros

for pt in plts:

in_file = pt
data = np.loadtxt(in_file, comments = ';')
fname = in_file.split('.')[0]

lon = data[:,0] #original 1D list
lat = data[:,1] #original 1D list
slcol = data[:,2] #z data

lon = (np.around(lon*2))/2 #round to nearest .0 or 0.5
lat = (np.around(lat*2))/2 #round to nearest .0 or 0.5

##keep the below between files

j=0

for i in slcol:
if lon[j]  0:
grid_lon_ind = 360+(lon[j]*2)
grid_lat_ind = 180+(lat[j]*2)
else:
grid_lon_ind = 360-(lon[j]*2)
grid_lat_ind = 180+(lat[j]*2)

if i  0:
dat[grid_lat_ind, grid_lon_ind] += i #add i'th value
n_vals[grid_lat_ind, grid_lon_ind] += 1 #increase cell counter by 1 
for each extra value

j+=1

dat = np.nan_to_num(dat/n_vals)

#create map object
fig = plt.figure()
m = Basemap(projection='ortho', lon_0=lon[(len(lon)/2)], lat_0=0, 
resolution='l', area_thresh=1.)

#m = Basemap(projection='moll',lon_0=0,resolution='c', area_thresh=1.)

X,Y = m(grid_lon, grid_lat)

#pass all 2d arrays to pcolor
im = m.pcolormesh(X,Y,dat)

#add coastlines, globe boundary and colourbar
m.drawcoastlines()
m.drawmapboundary()
m.drawparallels(np.arange(-90, 90,30))
m.drawmeridians(np.arange(-180,180,30))

fig.colorbar(im)
plt.title('CH20 and ting')
plt.savefig('binplot.png')

Thanks for your help,
Will.

View this message in context: Basemap/ orthographic projection plot 
doesn't respect globe boundary 
http://old.nabble.com/Basemap--orthographic-projection-plot-doesn%27t-respect-globe-boundary-tp28117654p28117654.html
Sent from the matplotlib - users mailing list archive 
http://old.nabble.com/matplotlib---users-f2906.html at Nabble.com.



--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev


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


from mpl_toolkits.basemap import Basemap, shiftgrid
import numpy as np
import matplotlib.pyplot as plt
# read in topo data (on a regular lat/lon grid)
# longitudes go from 20 to 380.
topoin = np.loadtxt('etopo20data.gz')
lons = np.loadtxt('etopo20lons.gz')
lats = np.loadtxt('etopo20lats.gz')
# shift data so lons go from -180 to 180 instead of 20 to 380.
topoin,lons = shiftgrid(180.,topoin,lons,start=False)
m = Basemap(projection='ortho',lon_0=-105,lat_0=40,resolution='l')
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/4.)+1; ny = int((m.ymax-m.ymin)/4.)+1
topodat,x,y =\
m.transform_scalar(topoin,lons,lats,nx,ny,returnxy=True,masked=True,order=1)
# create the figure.
fig=plt.figure(figsize=(8,8))
im = m.pcolormesh(x,y,topodat,cmap=plt.cm.jet)
m.drawcoastlines()
m.drawparallels(np.arange(0.,80,20.))
m.drawmeridians(np.arange(10.,360.,30.))
m.drawmapboundary()
plt.show()
--
Download Intel#174; Parallel Studio Eval
Try the new software tools for 

Re: [Matplotlib-users] Basemap/ orthographic projection plot doesn't respect globe boundary

2010-04-02 Thread Will Hewson

This is great Jeff, thanks for the help - I'll give it a try over the weekend
(it's bank holiday here in the UK!) and get back to you, if I'm still having
trouble I'll stick up the plotting data too... thanks again.

Will



Jeff Whitaker wrote:
 
 On 4/2/10 4:27 AM, Will Hewson wrote:
 Hi forum/ mailing list, When I plot in the orthographic projection I'm 
 getting the large artefact shown below extending away from the north 
 east of the globe. I'm not finding the same problem when plotting in a 
 full globe projection so I'm presuming the problem is with the way I'm 
 projecting everything rather than my data itself. I've included my 
 plotting code below, if anyone is able to spot some glaring omissions/ 
 errors I'd be most grateful (I've been using python/ matplotlib for 
 only a couple of weeks now!).
 Will:  I think what's happening is that pcolormesh is having trouble 
 dealing with the higher curvlinear grid, which becomes nearly 
 pathological near the horizon of the projection.  If you take a look at 
 the test.py file in the basemap examples directory, you'll see an 
 example orthographic plot that solves this problem by first 
 interpolating the data to a regular grid in projection coordinates (with 
 values over the plot horizon masked).  The example uses imshow, but 
 pcolormesh works as well.  A standalone version of the example using 
 pcolormesah  is attached, which uses data files in the basemap examples 
 directory.
 
 -Jeff
 
 from mpl_toolkits.basemap import Basemap, shiftgrid
 import numpy as np
 import matplotlib.pyplot as plt
 # read in topo data (on a regular lat/lon grid)
 # longitudes go from 20 to 380.
 topoin = np.loadtxt('etopo20data.gz')
 lons = np.loadtxt('etopo20lons.gz')
 lats = np.loadtxt('etopo20lats.gz')
 # shift data so lons go from -180 to 180 instead of 20 to 380.
 topoin,lons = shiftgrid(180.,topoin,lons,start=False)
 m = Basemap(projection='ortho',lon_0=-105,lat_0=40,resolution='l')
 # transform to nx x ny regularly spaced native projection grid
 nx = int((m.xmax-m.xmin)/4.)+1; ny = int((m.ymax-m.ymin)/4.)+1
 topodat,x,y =\
 m.transform_scalar(topoin,lons,lats,nx,ny,returnxy=True,masked=True,order=1)
 # create the figure.
 fig=plt.figure(figsize=(8,8))
 im = m.pcolormesh(x,y,topodat,cmap=plt.cm.jet)
 m.drawcoastlines()
 m.drawparallels(np.arange(0.,80,20.))
 m.drawmeridians(np.arange(10.,360.,30.))
 m.drawmapboundary()
 plt.show()
 
 

-- 
View this message in context: 
http://old.nabble.com/Basemap--orthographic-projection-plot-doesn%27t-respect-globe-boundary-tp28117654p28118555.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Basemap/ orthographic projection plot doesn't respect globe boundary

2010-04-02 Thread Jeff Whitaker
On 4/2/10 6:32 AM, Will Hewson wrote:
 This is great Jeff, thanks for the help - I'll give it a try over the weekend
 (it's bank holiday here in the UK!) and get back to you, if I'm still having
 trouble I'll stick up the plotting data too... thanks again.

 Will


Will:  I forgot to mention that contourf will work on your data without 
having to interpolate to projection coordinates.

-Jeff


 Jeff Whitaker wrote:

 On 4/2/10 4:27 AM, Will Hewson wrote:
  
 Hi forum/ mailing list, When I plot in the orthographic projection I'm
 getting the large artefact shown below extending away from the north
 east of the globe. I'm not finding the same problem when plotting in a
 full globe projection so I'm presuming the problem is with the way I'm
 projecting everything rather than my data itself. I've included my
 plotting code below, if anyone is able to spot some glaring omissions/
 errors I'd be most grateful (I've been using python/ matplotlib for
 only a couple of weeks now!).

 Will:  I think what's happening is that pcolormesh is having trouble
 dealing with the higher curvlinear grid, which becomes nearly
 pathological near the horizon of the projection.  If you take a look at
 the test.py file in the basemap examples directory, you'll see an
 example orthographic plot that solves this problem by first
 interpolating the data to a regular grid in projection coordinates (with
 values over the plot horizon masked).  The example uses imshow, but
 pcolormesh works as well.  A standalone version of the example using
 pcolormesah  is attached, which uses data files in the basemap examples
 directory.

 -Jeff

 from mpl_toolkits.basemap import Basemap, shiftgrid
 import numpy as np
 import matplotlib.pyplot as plt
 # read in topo data (on a regular lat/lon grid)
 # longitudes go from 20 to 380.
 topoin = np.loadtxt('etopo20data.gz')
 lons = np.loadtxt('etopo20lons.gz')
 lats = np.loadtxt('etopo20lats.gz')
 # shift data so lons go from -180 to 180 instead of 20 to 380.
 topoin,lons = shiftgrid(180.,topoin,lons,start=False)
 m = Basemap(projection='ortho',lon_0=-105,lat_0=40,resolution='l')
 # transform to nx x ny regularly spaced native projection grid
 nx = int((m.xmax-m.xmin)/4.)+1; ny = int((m.ymax-m.ymin)/4.)+1
 topodat,x,y =\
 m.transform_scalar(topoin,lons,lats,nx,ny,returnxy=True,masked=True,order=1)
 # create the figure.
 fig=plt.figure(figsize=(8,8))
 im = m.pcolormesh(x,y,topodat,cmap=plt.cm.jet)
 m.drawcoastlines()
 m.drawparallels(np.arange(0.,80,20.))
 m.drawmeridians(np.arange(10.,360.,30.))
 m.drawmapboundary()
 plt.show()


  



--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Changing the font

2010-04-02 Thread Michael Droettboom
Can you set verbose.level to debug-annoying in your matplotlibrc 
file, and then send the output to this list.  That may help us track 
down where the font lookup is failing.  Also, what platform and version 
of matplotlib are you running?

Mike

Alex S wrote:
 Hi, sorry I wasn't too clear... I changed that, but I don't seem to be able
 to choose between the different serif fonts, it just always gives me the
 default...



 Alex S wrote:
   
 Hi there,
 I'm trying to change the font default on my graph to New Century
 Schoolbook.  I'm trying to do this by editing the matplotlibrc file. 
 Unfortunately, although I'm able to change the font.family, I can't figure
 out how to make it use something other than the default in the family... 
 I tried changing the list further down to only include the font I want,
 like this:

 font.serif  : New Century Schoolbook #Bitstream Vera Serif, New
 Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman,
 Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif

 (note I commented out the other fonts, just rearranging the list to put
 New Century Schoolbook first didn't seem to work either)

 Could anyone tell me what I'm doing wrong?
 Thanks a lot!
 Alex


 

   

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] speed up imports?

2010-04-02 Thread Michael Droettboom
My gut says it's probably the GUI framework import that is dominating 
the time.  Which backend are you using?  Does importing it take a large 
amount of time as well? 

Can you provide a profiler output file we can examine to narrow it 
down?  The following from a command prompt should be sufficient to write 
out a file called import.prof:

  python.exe -c import cProfile; prof=cProfile.Profile(); 
prof.run('import pylab', 'import.prof')

Mike

C M wrote:
 On Thu, Apr 1, 2010 at 7:17 PM, Eric Firing efir...@hawaii.edu wrote:
   
 Andrew Kelly wrote:
 
 Has anyone had any success in speeding up the mpl imports?

 import matplotlib.pyplot as plt
 ( or from matplotlib.figure import Figure)

 takes 6 full seconds to load.  That seems excessive.  Any ideas?

 -Andy
   
 Andy,

 A couple replies came back directly to me (probably intended for the
 list, though), and both reported results similar to yours, on Windows
 machines only.  What OS and version are you running?
 

 Sorry Eric, that was indeed intended for the list.  Just for the
 list's sake, I'll repeat it:

 It takes longer than any other Python module for me, too, about 5-6
 seconds on a cold load (on Windows), though faster on a warm load.
  I am running it locally on a laptop that is 1.7 GHz Intel Pentium
 laptop with 1Meg RAM.

 And I should add:  I don't currently have Linux installed, but will
 soon again I hope, and I will take note of how long it takes on Linux.

 Thanks,
 Che

 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
   

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] MacOS 10.6 install dependency building fails (r8214)

2010-04-02 Thread Thomas Robitaille


Thomas Robitaille wrote:
 
 It looks like the zlib website removes previous version of its library
 that were previously available for download, so the part in make.osx where
 http://www.zlib.net/zlib-1.2.3.tar.gz is fetched now fails (since the
 current version is 1.2.4). The error in the matplotlib building is not
 explicit enough (incorrect archive type) - maybe one could catch such 404s
 and print out an error suggesting to increase the ZLIBVERSION variable?
 
 I tried changing ZLIBVERSION to 1.2.4 and the following occurs when
 building zlib:
 
 ...
 make[1]: *** No rule to make target `libz.dylib', needed by
 `install-libs'.  Stop.
 make[1]: *** Waiting for unfinished jobs
 make: *** [zlib] Error 2
 

I have submitted a simple patch that fixes all these issues:

https://sourceforge.net/tracker/?func=detailaid=2981126group_id=80706atid=560722

Matplotlib then compiles 'out of the box' for 10.6.

Cheers,

Thomas

-- 
View this message in context: 
http://old.nabble.com/MacOS-10.6-install-dependency-building-fails-%28r8214%29-tp28069099p28119205.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] speed up imports?

2010-04-02 Thread Gökhan Sever
On Fri, Apr 2, 2010 at 8:28 AM, Michael Droettboom md...@stsci.edu wrote:

 My gut says it's probably the GUI framework import that is dominating
 the time.  Which backend are you using?  Does importing it take a large
 amount of time as well?

 Can you provide a profiler output file we can examine to narrow it
 down?  The following from a command prompt should be sufficient to write
 out a file called import.prof:

  python.exe -c import cProfile; prof=cProfile.Profile();
 prof.run('import pylab', 'import.prof')

 Mike


Just for the records,

It reads as:

python -c import cProfile; cProfile.run('import pylab',
filename='test.out')

in Python 2.6.2

These helped me to load the profile output:

import pstats
stats = pstats.Stats(test.out)
stats.print_stats()

-- 
Gökhan
--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] EPS files with LaTeX are invalid

2010-04-02 Thread Thomas Robitaille
It seems that removing 'restore' on line 1073 of the test_tex_r8216.eps file 
fixes the problem, although I don't understand postscript well enough to 
understand why that is.

Thomas

On Apr 2, 2010, at 9:30 AM, Michael Droettboom wrote:

 Can you provide us with the EPS file?  What version of LaTeX is this?
 
 Mike
 
 Thomas Robitaille wrote:
 Hello,
 
 I upgraded to the latest svn version of matplotlib today, and found that eps 
 files produced with the system latex now seem to be invalid. For example, if 
 I run the following script
 
 import matplotlib
 matplotlib.use('Agg')
 import matplotlib.pyplot as mpl
 
 mpl.rc('text', usetex=False)
 
 fig = mpl.figure()
 ax = fig.add_subplot(1,1,1)
 fig.savefig('test_notex.eps')
 
 mpl.rc('text', usetex=True)
 
 fig = mpl.figure()
 ax = fig.add_subplot(1,1,1)
 fig.savefig('test_tex.eps')
 
 and try running pstopdf on them (on MacOS 10.6) I get the following
 
 air:air tom$ pstopdf test_tex.eps %%[ Warning: Empty job. No PDF file 
 produced. ] %%
 air:air tom$ pstopdf test_notex.eps air:air tom$ 
 So the file with the system LaTeX enabled no longer works. ps2pdf still 
 works, but the error with pstopdf is important, because for example 
 Preview.app on mac relies on pstopdf, not ps2pdf.
 
 I tried this on two different computers under MacOS 10.6, and tried with 
 ghostscript 8.70 and 8.71 installed, and the problem occurs either way.
 
 Does anyone know what might be causing this? I submitted a bug report a 
 little while back about this
 
 https://sourceforge.net/tracker/?func=detailaid=2974953group_id=80706atid=560720
 
 Thanks in advance for any help,
 
 Thomas
 
 
 
 
 
 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  
 
 -- 
 Michael Droettboom
 Science Software Branch
 Operations and Engineering Division
 Space Telescope Science Institute
 Operated by AURA for NASA
 


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Cmap creation

2010-04-02 Thread Bruce Ford
Below is the example script (sorry!).  I've tried all three methods of
establishing a colormap to no avail.  The most promising looked like
option 2, but that gave me the AttributeError: 'module' object has no
attribute 'register_cmap' error.

I'm getting this error with:
Python 2.4 (user requirement because this application I'm building
will live on a RHEL5 server)
matplotlib 0.99.1.1
numpy 1.3.0

Could this be a versioning issue?

Bruce

#!/usr/bin/env python

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap



Example: suppose you want red to increase from 0 to 1 over the bottom
half, green to do the same over the middle half, and blue over the top
half.  Then you would use:

cdict = {'red':   ((0.0,  0.0, 0.0),
   (0.5,  1.0, 1.0),
   (1.0,  1.0, 1.0)),

 'green': ((0.0,  0.0, 0.0),
   (0.25, 0.0, 0.0),
   (0.75, 1.0, 1.0),
   (1.0,  1.0, 1.0)),

 'blue':  ((0.0,  0.0, 0.0),
   (0.5,  0.0, 0.0),
   (1.0,  1.0, 1.0))}

If, as in this example, there are no discontinuities in the r, g, and b
components, then it is quite simple: the second and third element of
each tuple, above, is the same--call it y.  The first element (x)
defines interpolation intervals over the full range of 0 to 1, and it
must span that whole range.  In other words, the values of x divide the
0-to-1 range into a set of segments, and y gives the end-point color
values for each segment.

Now consider the green. cdict['green'] is saying that for
0 = x = 0.25, y is zero; no green.
0.25  x = 0.75, y varies linearly from 0 to 1.
x  0.75, y remains at 1, full green.

If there are discontinuities, then it is a little more complicated.
Label the 3 elements in each row in the cdict entry for a given color as
(x, y0, y1).  Then for values of x between x[i] and x[i+1] the color
value is interpolated between y1[i] and y0[i+1].

Going back to the cookbook example, look at cdict['red']; because y0 !=
y1, it is saying that for x from 0 to 0.5, red increases from 0 to 1,
but then it jumps down, so that for x from 0.5 to 1, red increases from
0.7 to 1.  Green ramps from 0 to 1 as x goes from 0 to 0.5, then jumps
back to 0, and ramps back to 1 as x goes from 0.5 to 1.

row i:   x  y0  y1
/
   /
row i+1: x  y0  y1

Above is an attempt to show that for x in the range x[i] to x[i+1], the
interpolation is between y1[i] and y0[i+1].  So, y0[0] and y1[-1] are
never used.





cdict1 = {'red':   ((0.0, 0.0, 0.0),
   (0.5, 0.0, 0.1),
   (1.0, 1.0, 1.0)),

 'green': ((0.0, 0.0, 0.0),
   (1.0, 0.0, 0.0)),

 'blue':  ((0.0, 0.0, 1.0),
   (0.5, 0.1, 0.0),
   (1.0, 0.0, 0.0))
}

cdict2 = {'red':   ((0.0, 0.0, 0.0),
   (0.5, 0.0, 1.0),
   (1.0, 0.1, 1.0)),

 'green': ((0.0, 0.0, 0.0),
   (1.0, 0.0, 0.0)),

 'blue':  ((0.0, 0.0, 0.1),
   (0.5, 1.0, 0.0),
   (1.0, 0.0, 0.0))
}

cdict3 = {'red':  ((0.0, 0.0, 0.0),
   (0.25,0.0, 0.0),
   (0.5, 0.8, 1.0),
   (0.75,1.0, 1.0),
   (1.0, 0.4, 1.0)),

 'green': ((0.0, 0.0, 0.0),
   (0.25,0.0, 0.0),
   (0.5, 0.9, 0.9),
   (0.75,0.0, 0.0),
   (1.0, 0.0, 0.0)),

 'blue':  ((0.0, 0.0, 0.4),
   (0.25,1.0, 1.0),
   (0.5, 1.0, 0.8),
   (0.75,0.0, 0.0),
   (1.0, 0.0, 0.0))
}

# Now we will use this example to illustrate 3 ways of
# handling custom colormaps.
# First, the most direct and explicit:

blue_red1 = LinearSegmentedColormap('BlueRed1', cdict1)

# Second, create the map explicitly and register it.
# Like the first method, this method works with any kind
# of Colormap, not just
# a LinearSegmentedColormap:

blue_red2 = LinearSegmentedColormap('BlueRed2', cdict2)
plt.register_cmap(cmap=blue_red2)

# Third, for LinearSegmentedColormap only,
# leave everything to register_cmap:

plt.register_cmap(name='BlueRed3', data=cdict3) # optional lut kwarg

x = np.arange(0, np.pi, 0.1)
y = np.arange(0, 2*np.pi, 0.1)
X, Y = np.meshgrid(x,y)
Z = np.cos(X) * np.sin(Y)

plt.figure(figsize=(10,4))
plt.subplots_adjust(wspace=0.3)

plt.subplot(1,3,1)
plt.imshow(Z, interpolation='nearest', cmap=blue_red1)
plt.colorbar()

plt.subplot(1,3,2)
cmap = plt.get_cmap('BlueRed2')
plt.imshow(Z, interpolation='nearest', cmap=cmap)
plt.colorbar()

# Now we will set the third cmap as the default.  One would
# not normally do this in the middle of a script like this;
# it is done here just to illustrate the method.

plt.rcParams['image.cmap'] = 'BlueRed3'

# Also see below for an alternative, particularly for
# interactive use.


Re: [Matplotlib-users] EPS files with LaTeX are invalid

2010-04-02 Thread Jae-Joon Lee
I just had a quick look, but while extra restore could be a problem,
the erroneous one may not be the one at line 1073, but the one at line
1066.

I believe that the restore at 1073 is written by pstoeps function
in backend_ps.py, and this function did write a matching save at
line 11.

Regards,

-JJ




On Fri, Apr 2, 2010 at 10:35 AM, Thomas Robitaille
thomas.robitai...@gmail.com wrote:
 It seems that removing 'restore' on line 1073 of the test_tex_r8216.eps file 
 fixes the problem, although I don't understand postscript well enough to 
 understand why that is.

 Thomas

 On Apr 2, 2010, at 9:30 AM, Michael Droettboom wrote:

 Can you provide us with the EPS file?  What version of LaTeX is this?

 Mike

 Thomas Robitaille wrote:
 Hello,

 I upgraded to the latest svn version of matplotlib today, and found that 
 eps files produced with the system latex now seem to be invalid. For 
 example, if I run the following script

 import matplotlib
 matplotlib.use('Agg')
 import matplotlib.pyplot as mpl

 mpl.rc('text', usetex=False)

 fig = mpl.figure()
 ax = fig.add_subplot(1,1,1)
 fig.savefig('test_notex.eps')

 mpl.rc('text', usetex=True)

 fig = mpl.figure()
 ax = fig.add_subplot(1,1,1)
 fig.savefig('test_tex.eps')

 and try running pstopdf on them (on MacOS 10.6) I get the following

 air:air tom$ pstopdf test_tex.eps %%[ Warning: Empty job. No PDF file 
 produced. ] %%
 air:air tom$ pstopdf test_notex.eps air:air tom$
 So the file with the system LaTeX enabled no longer works. ps2pdf still 
 works, but the error with pstopdf is important, because for example 
 Preview.app on mac relies on pstopdf, not ps2pdf.

 I tried this on two different computers under MacOS 10.6, and tried with 
 ghostscript 8.70 and 8.71 installed, and the problem occurs either way.

 Does anyone know what might be causing this? I submitted a bug report a 
 little while back about this

 https://sourceforge.net/tracker/?func=detailaid=2974953group_id=80706atid=560720

 Thanks in advance for any help,

 Thomas





 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


 --
 Michael Droettboom
 Science Software Branch
 Operations and Engineering Division
 Space Telescope Science Institute
 Operated by AURA for NASA



 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] EPS files with LaTeX are invalid

2010-04-02 Thread Michael Droettboom
At least on my Linux box with gs 7.07, I have to use epstopdf (not 
pstopdf) to convert an eps file to a pdf.  ps2pdf does work for both .ps 
and .eps files however.

It looks like the 0.99.1.1 file is not in fact an .eps file, but a .ps 
file, (it certainly hasn't had the ps2eps function run on it) and I 
think it was probably a bug (now fixed) that 0.99.1.1 was writing out 
the wrong kind of file. 

It seems the relevant change is in r8102: fix some issues in the bbox 
after the postscript distiller is run.  This change removed a commented 
out call to ps2eps.  I'm a bit out of my depth here as to why that 
change was made, and why .eps files seemingly haven't been true .eps 
files for a long time prior to that change.  Anyone else?

Mike

Thomas Robitaille wrote:
 It seems that removing 'restore' on line 1073 of the test_tex_r8216.eps file 
 fixes the problem, although I don't understand postscript well enough to 
 understand why that is.

 Thomas

 On Apr 2, 2010, at 9:30 AM, Michael Droettboom wrote:

   
 Can you provide us with the EPS file?  What version of LaTeX is this?

 Mike

 Thomas Robitaille wrote:
 
 Hello,

 I upgraded to the latest svn version of matplotlib today, and found that 
 eps files produced with the system latex now seem to be invalid. For 
 example, if I run the following script

 import matplotlib
 matplotlib.use('Agg')
 import matplotlib.pyplot as mpl

 mpl.rc('text', usetex=False)

 fig = mpl.figure()
 ax = fig.add_subplot(1,1,1)
 fig.savefig('test_notex.eps')

 mpl.rc('text', usetex=True)

 fig = mpl.figure()
 ax = fig.add_subplot(1,1,1)
 fig.savefig('test_tex.eps')

 and try running pstopdf on them (on MacOS 10.6) I get the following

 air:air tom$ pstopdf test_tex.eps %%[ Warning: Empty job. No PDF file 
 produced. ] %%
 air:air tom$ pstopdf test_notex.eps air:air tom$ 
 So the file with the system LaTeX enabled no longer works. ps2pdf still 
 works, but the error with pstopdf is important, because for example 
 Preview.app on mac relies on pstopdf, not ps2pdf.

 I tried this on two different computers under MacOS 10.6, and tried with 
 ghostscript 8.70 and 8.71 installed, and the problem occurs either way.

 Does anyone know what might be causing this? I submitted a bug report a 
 little while back about this

 https://sourceforge.net/tracker/?func=detailaid=2974953group_id=80706atid=560720

 Thanks in advance for any help,

 Thomas





 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  
   
 -- 
 Michael Droettboom
 Science Software Branch
 Operations and Engineering Division
 Space Telescope Science Institute
 Operated by AURA for NASA

 

   

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] EPS files with LaTeX are invalid

2010-04-02 Thread Thomas Robitaille
I just tried running epstopdf, and this does work correctly, so maybe now the 
only issue is that Preview.app on mac always uses pstopdf, even for eps files? 
(which then is not a matplotlib issue) I also checked that giving the file the 
extension '.ps' produces a ps file, and that does open correctly in Preview.app.

Cheers,

Tom

On Apr 2, 2010, at 11:20 AM, Michael Droettboom wrote:

 At least on my Linux box with gs 7.07, I have to use epstopdf (not pstopdf) 
 to convert an eps file to a pdf.  ps2pdf does work for both .ps and .eps 
 files however.
 
 It looks like the 0.99.1.1 file is not in fact an .eps file, but a .ps file, 
 (it certainly hasn't had the ps2eps function run on it) and I think it was 
 probably a bug (now fixed) that 0.99.1.1 was writing out the wrong kind of 
 file. 
 It seems the relevant change is in r8102: fix some issues in the bbox after 
 the postscript distiller is run.  This change removed a commented out call 
 to ps2eps.  I'm a bit out of my depth here as to why that change was made, 
 and why .eps files seemingly haven't been true .eps files for a long time 
 prior to that change.  Anyone else?
 
 Mike
 
 Thomas Robitaille wrote:
 It seems that removing 'restore' on line 1073 of the test_tex_r8216.eps file 
 fixes the problem, although I don't understand postscript well enough to 
 understand why that is.
 
 Thomas
 
 On Apr 2, 2010, at 9:30 AM, Michael Droettboom wrote:
 
  
 Can you provide us with the EPS file?  What version of LaTeX is this?
 
 Mike
 
 Thomas Robitaille wrote:

 Hello,
 
 I upgraded to the latest svn version of matplotlib today, and found that 
 eps files produced with the system latex now seem to be invalid. For 
 example, if I run the following script
 
 import matplotlib
 matplotlib.use('Agg')
 import matplotlib.pyplot as mpl
 
 mpl.rc('text', usetex=False)
 
 fig = mpl.figure()
 ax = fig.add_subplot(1,1,1)
 fig.savefig('test_notex.eps')
 
 mpl.rc('text', usetex=True)
 
 fig = mpl.figure()
 ax = fig.add_subplot(1,1,1)
 fig.savefig('test_tex.eps')
 
 and try running pstopdf on them (on MacOS 10.6) I get the following
 
 air:air tom$ pstopdf test_tex.eps %%[ Warning: Empty job. No PDF file 
 produced. ] %%
 air:air tom$ pstopdf test_notex.eps air:air tom$ So the file with the 
 system LaTeX enabled no longer works. ps2pdf still works, but the error 
 with pstopdf is important, because for example Preview.app on mac relies 
 on pstopdf, not ps2pdf.
 
 I tried this on two different computers under MacOS 10.6, and tried with 
 ghostscript 8.70 and 8.71 installed, and the problem occurs either way.
 
 Does anyone know what might be causing this? I submitted a bug report a 
 little while back about this
 
 https://sourceforge.net/tracker/?func=detailaid=2974953group_id=80706atid=560720
 
 Thanks in advance for any help,
 
 Thomas
 
 
 
 
 
 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
   
 -- 
 Michael Droettboom
 Science Software Branch
 Operations and Engineering Division
 Space Telescope Science Institute
 Operated by AURA for NASA
 

 
  
 
 -- 
 Michael Droettboom
 Science Software Branch
 Operations and Engineering Division
 Space Telescope Science Institute
 Operated by AURA for NASA
 


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Cmap creation

2010-04-02 Thread Eric Firing
Bruce Ford wrote:
 Below is the example script (sorry!).  I've tried all three methods of
 establishing a colormap to no avail.  The most promising looked like
 option 2, but that gave me the AttributeError: 'module' object has no
 attribute 'register_cmap' error.
 
 I'm getting this error with:
 Python 2.4 (user requirement because this application I'm building
 will live on a RHEL5 server)
 matplotlib 0.99.1.1
 numpy 1.3.0
 
 Could this be a versioning issue?

Yes, register_cmap is quite new--but it is just a convenience, and not 
at all necessary.  Use of a custom cmap without register_cmap is 
illustrated in the first subplot of the example; you could modify the 
example so that all of the subplots are made without register_cmap.

Eric


 
 Bruce
 
 #!/usr/bin/env python
 
 import numpy as np
 import matplotlib.pyplot as plt
 from matplotlib.colors import LinearSegmentedColormap
 
 
 
 Example: suppose you want red to increase from 0 to 1 over the bottom
 half, green to do the same over the middle half, and blue over the top
 half.  Then you would use:
 
 cdict = {'red':   ((0.0,  0.0, 0.0),
(0.5,  1.0, 1.0),
(1.0,  1.0, 1.0)),
 
  'green': ((0.0,  0.0, 0.0),
(0.25, 0.0, 0.0),
(0.75, 1.0, 1.0),
(1.0,  1.0, 1.0)),
 
  'blue':  ((0.0,  0.0, 0.0),
(0.5,  0.0, 0.0),
(1.0,  1.0, 1.0))}
 
 If, as in this example, there are no discontinuities in the r, g, and b
 components, then it is quite simple: the second and third element of
 each tuple, above, is the same--call it y.  The first element (x)
 defines interpolation intervals over the full range of 0 to 1, and it
 must span that whole range.  In other words, the values of x divide the
 0-to-1 range into a set of segments, and y gives the end-point color
 values for each segment.
 
 Now consider the green. cdict['green'] is saying that for
 0 = x = 0.25, y is zero; no green.
 0.25  x = 0.75, y varies linearly from 0 to 1.
 x  0.75, y remains at 1, full green.
 
 If there are discontinuities, then it is a little more complicated.
 Label the 3 elements in each row in the cdict entry for a given color as
 (x, y0, y1).  Then for values of x between x[i] and x[i+1] the color
 value is interpolated between y1[i] and y0[i+1].
 
 Going back to the cookbook example, look at cdict['red']; because y0 !=
 y1, it is saying that for x from 0 to 0.5, red increases from 0 to 1,
 but then it jumps down, so that for x from 0.5 to 1, red increases from
 0.7 to 1.  Green ramps from 0 to 1 as x goes from 0 to 0.5, then jumps
 back to 0, and ramps back to 1 as x goes from 0.5 to 1.
 
 row i:   x  y0  y1
 /
/
 row i+1: x  y0  y1
 
 Above is an attempt to show that for x in the range x[i] to x[i+1], the
 interpolation is between y1[i] and y0[i+1].  So, y0[0] and y1[-1] are
 never used.
 
 
 
 
 
 cdict1 = {'red':   ((0.0, 0.0, 0.0),
(0.5, 0.0, 0.1),
(1.0, 1.0, 1.0)),
 
  'green': ((0.0, 0.0, 0.0),
(1.0, 0.0, 0.0)),
 
  'blue':  ((0.0, 0.0, 1.0),
(0.5, 0.1, 0.0),
(1.0, 0.0, 0.0))
 }
 
 cdict2 = {'red':   ((0.0, 0.0, 0.0),
(0.5, 0.0, 1.0),
(1.0, 0.1, 1.0)),
 
  'green': ((0.0, 0.0, 0.0),
(1.0, 0.0, 0.0)),
 
  'blue':  ((0.0, 0.0, 0.1),
(0.5, 1.0, 0.0),
(1.0, 0.0, 0.0))
 }
 
 cdict3 = {'red':  ((0.0, 0.0, 0.0),
(0.25,0.0, 0.0),
(0.5, 0.8, 1.0),
(0.75,1.0, 1.0),
(1.0, 0.4, 1.0)),
 
  'green': ((0.0, 0.0, 0.0),
(0.25,0.0, 0.0),
(0.5, 0.9, 0.9),
(0.75,0.0, 0.0),
(1.0, 0.0, 0.0)),
 
  'blue':  ((0.0, 0.0, 0.4),
(0.25,1.0, 1.0),
(0.5, 1.0, 0.8),
(0.75,0.0, 0.0),
(1.0, 0.0, 0.0))
 }
 
 # Now we will use this example to illustrate 3 ways of
 # handling custom colormaps.
 # First, the most direct and explicit:
 
 blue_red1 = LinearSegmentedColormap('BlueRed1', cdict1)
 
 # Second, create the map explicitly and register it.
 # Like the first method, this method works with any kind
 # of Colormap, not just
 # a LinearSegmentedColormap:
 
 blue_red2 = LinearSegmentedColormap('BlueRed2', cdict2)
 plt.register_cmap(cmap=blue_red2)
 
 # Third, for LinearSegmentedColormap only,
 # leave everything to register_cmap:
 
 plt.register_cmap(name='BlueRed3', data=cdict3) # optional lut kwarg
 
 x = np.arange(0, np.pi, 0.1)
 y = np.arange(0, 2*np.pi, 0.1)
 X, Y = np.meshgrid(x,y)
 Z = np.cos(X) * np.sin(Y)
 
 plt.figure(figsize=(10,4))
 plt.subplots_adjust(wspace=0.3)
 
 plt.subplot(1,3,1)
 plt.imshow(Z, 

[Matplotlib-users] visualizing colormaps for complex functions

2010-04-02 Thread Guy Rutenberg
Hi,

Is there a way to generate colormaps for complex-valued functions using
matplotlib? The type of plots I'm looking for are like the plots in:
http://commons.wikimedia.org/wiki/User:Jan_Homann/Mathematics

Thanks in advance,

Guy


http://www.guyrutenberg.com
--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] speed up imports?

2010-04-02 Thread Michael Droettboom
Can you provide the actual saved profiler data?  The output of the 
command itself doesn't provide enough information to diagnose the 
problem, since it doesn't have full file paths etc.

When you do (thanks Gökhan for the less verbose version):

  python.exe -c import cProfile; cProfile.run('import pylab', 'test.out')

this should produce a binary file test.out that can be loaded with the 
pstats module and used by GUI tools such as KCacheGrind to help us get 
to the bottom of this.

Mike

Andrew Kelly wrote:
 I'm back.

 My backend is wx.  Import wx does not really take much time to 
 import at all.  In fact time.time() before and after = 0.0

 Some computer details:
 Processor: AMD Phenom IIx4 810 Processor 2.6 GHz
 RAM: 8.00 GB

 As for the cProfiler output on pylab, I have attached the output as 
 test.txt.
  
 -Andy

 On Fri, Apr 2, 2010 at 7:22 AM, Gökhan Sever gokhanse...@gmail.com 
 mailto:gokhanse...@gmail.com wrote:



 On Fri, Apr 2, 2010 at 8:28 AM, Michael Droettboom
 md...@stsci.edu mailto:md...@stsci.edu wrote:

 My gut says it's probably the GUI framework import that is
 dominating
 the time.  Which backend are you using?  Does importing it
 take a large
 amount of time as well?

 Can you provide a profiler output file we can examine to narrow it
 down?  The following from a command prompt should be
 sufficient to write
 out a file called import.prof:

  python.exe -c import cProfile; prof=cProfile.Profile();
 prof.run('import pylab', 'import.prof')

 Mike


 Just for the records,

 It reads as:

 python -c import cProfile; cProfile.run('import pylab',
 filename='test.out')

 in Python 2.6.2

 These helped me to load the profile output:

 import pstats
 stats = pstats.Stats(test.out)
 stats.print_stats()

 -- 
 Gökhan

 
 --
 Download Intel#174; Parallel Studio Eval
 Try the new software tools for yourself. Speed compiling, find bugs
 proactively, and fine-tune applications for parallel performance.
 See why Intel Parallel Studio got high marks during beta.
 http://p.sf.net/sfu/intel-sw-dev
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 mailto:Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] speed up imports?

2010-04-02 Thread Michael Droettboom
It looks like most of the time is being taken up by pytz (timezone 
library), which opens ~500 files.  How does the total time of import 
pytz compare?

Mike

Andrew Kelly wrote:
 I see.  I was wondering why it spit out a binary file.

 test.out is attached...

 -Andy

 On Fri, Apr 2, 2010 at 10:55 AM, Michael Droettboom md...@stsci.edu 
 mailto:md...@stsci.edu wrote:

 Can you provide the actual saved profiler data?  The output of the
 command itself doesn't provide enough information to diagnose the
 problem, since it doesn't have full file paths etc.

 When you do (thanks Gökhan for the less verbose version):

  python.exe -c import cProfile; cProfile.run('import pylab',
 'test.out')

 this should produce a binary file test.out that can be loaded
 with the pstats module and used by GUI tools such as KCacheGrind
 to help us get to the bottom of this.

 Mike

 Andrew Kelly wrote:

 I'm back.

 My backend is wx.  Import wx does not really take much time
 to import at all.  In fact time.time() before and after = 0.0

 Some computer details:
 Processor: AMD Phenom IIx4 810 Processor 2.6 GHz
 RAM: 8.00 GB

 As for the cProfiler output on pylab, I have attached the
 output as test.txt.
  -Andy

 On Fri, Apr 2, 2010 at 7:22 AM, Gökhan Sever
 gokhanse...@gmail.com mailto:gokhanse...@gmail.com
 mailto:gokhanse...@gmail.com mailto:gokhanse...@gmail.com
 wrote:



On Fri, Apr 2, 2010 at 8:28 AM, Michael Droettboom
md...@stsci.edu mailto:md...@stsci.edu
 mailto:md...@stsci.edu mailto:md...@stsci.edu wrote:

My gut says it's probably the GUI framework import that is
dominating
the time.  Which backend are you using?  Does importing it
take a large
amount of time as well?

Can you provide a profiler output file we can examine
 to narrow it
down?  The following from a command prompt should be
sufficient to write
out a file called import.prof:

 python.exe -c import cProfile; prof=cProfile.Profile();
prof.run('import pylab', 'import.prof')

Mike


Just for the records,

It reads as:

python -c import cProfile; cProfile.run('import pylab',
filename='test.out')

in Python 2.6.2

These helped me to load the profile output:

import pstats
stats = pstats.Stats(test.out)
stats.print_stats()

-- Gökhan

  
  
 --
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling,
 find bugs
proactively, and fine-tune applications for parallel
 performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
 mailto:Matplotlib-users@lists.sourceforge.net
mailto:Matplotlib-users@lists.sourceforge.net
 mailto:Matplotlib-users@lists.sourceforge.net

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



 -- 
 Michael Droettboom
 Science Software Branch
 Operations and Engineering Division
 Space Telescope Science Institute
 Operated by AURA for NASA



-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] speed up imports?

2010-04-02 Thread Andrew Kelly
import pytz only took 0.0 seconds.

I actually just ran that pstats module and there is one line that stuck out
at me:
  ncalls  tottime  percall  cumtime  percall filename:lineno(function)
10.0000.0000.0000.000
C:\Python26\lib\os.py:35(_get_exports_list)
  5603.1070.0063.1070.006 {open}

That is ~50% of the load time.  I have 0 idea what this is though.

Let me try this on my os machine.

-Andy

On Fri, Apr 2, 2010 at 12:31 PM, Michael Droettboom md...@stsci.edu wrote:

 It looks like most of the time is being taken up by pytz (timezone
 library), which opens ~500 files.  How does the total time of import pytz
 compare?

 Mike

 Andrew Kelly wrote:

 I see.  I was wondering why it spit out a binary file.

 test.out is attached...

 -Andy

 On Fri, Apr 2, 2010 at 10:55 AM, Michael Droettboom md...@stsci.edumailto:
 md...@stsci.edu wrote:

Can you provide the actual saved profiler data?  The output of the
command itself doesn't provide enough information to diagnose the
problem, since it doesn't have full file paths etc.

When you do (thanks Gökhan for the less verbose version):

 python.exe -c import cProfile; cProfile.run('import pylab',
'test.out')

this should produce a binary file test.out that can be loaded
with the pstats module and used by GUI tools such as KCacheGrind
to help us get to the bottom of this.

Mike

Andrew Kelly wrote:

I'm back.

My backend is wx.  Import wx does not really take much time
to import at all.  In fact time.time() before and after = 0.0

Some computer details:
Processor: AMD Phenom IIx4 810 Processor 2.6 GHz
RAM: 8.00 GB

As for the cProfiler output on pylab, I have attached the
output as test.txt.
 -Andy

On Fri, Apr 2, 2010 at 7:22 AM, Gökhan Sever
gokhanse...@gmail.com mailto:gokhanse...@gmail.com
mailto:gokhanse...@gmail.com mailto:gokhanse...@gmail.com

wrote:



   On Fri, Apr 2, 2010 at 8:28 AM, Michael Droettboom
   md...@stsci.edu mailto:md...@stsci.edu
 mailto:md...@stsci.edu mailto:md...@stsci.edu wrote:

   My gut says it's probably the GUI framework import that is
   dominating
   the time.  Which backend are you using?  Does importing it
   take a large
   amount of time as well?

   Can you provide a profiler output file we can examine
to narrow it
   down?  The following from a command prompt should be
   sufficient to write
   out a file called import.prof:

python.exe -c import cProfile; prof=cProfile.Profile();
   prof.run('import pylab', 'import.prof')

   Mike


   Just for the records,

   It reads as:

   python -c import cProfile; cProfile.run('import pylab',
   filename='test.out')

   in Python 2.6.2

   These helped me to load the profile output:

   import pstats
   stats = pstats.Stats(test.out)
   stats.print_stats()

   -- Gökhan


  
 --
   Download Intel#174; Parallel Studio Eval
   Try the new software tools for yourself. Speed compiling,
find bugs
   proactively, and fine-tune applications for parallel
performance.
   See why Intel Parallel Studio got high marks during beta.
   http://p.sf.net/sfu/intel-sw-dev
   ___
   Matplotlib-users mailing list
   Matplotlib-users@lists.sourceforge.net
mailto:Matplotlib-users@lists.sourceforge.net
   mailto:Matplotlib-users@lists.sourceforge.net
mailto:Matplotlib-users@lists.sourceforge.net

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



-- Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA



 --
 Michael Droettboom
 Science Software Branch
 Operations and Engineering Division
 Space Telescope Science Institute
 Operated by AURA for NASA


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] speed up imports?

2010-04-02 Thread Eric Firing
Andrew Kelly wrote:
 import pytz only took 0.0 seconds.
  

Sounds like it was already imported, so you were not really timing that 
import.

On linux (ubuntu 9.10, Lenovo T60 laptop) importing pytz takes longer 
than importing numpy:


efir...@manini:~$ time python -c import pytz

real0m0.203s
user0m0.144s
sys 0m0.052s
efir...@manini:~$ time python -c import pylab

real0m0.626s
user0m0.480s
sys 0m0.124s

efir...@manini:~$ time python -c import numpy

real0m0.113s
user0m0.088s
sys 0m0.020s

(Probably everything is in cache in these tests; repeats yielded similar 
results.)

Eric


 I actually just ran that pstats module and there is one line that stuck 
 out at me:
   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
 10.0000.0000.0000.000 
 C:\Python26\lib\os.py:35(_get_exports_list)
   5603.1070.0063.1070.006 {open}
  
 That is ~50% of the load time.  I have 0 idea what this is though.
  
 Let me try this on my os machine.
  
 -Andy
 
 On Fri, Apr 2, 2010 at 12:31 PM, Michael Droettboom md...@stsci.edu 
 mailto:md...@stsci.edu wrote:
 
 It looks like most of the time is being taken up by pytz (timezone
 library), which opens ~500 files.  How does the total time of
 import pytz compare?
 
 Mike
 
 Andrew Kelly wrote:
 
 I see.  I was wondering why it spit out a binary file.
 
 test.out is attached...
 
 -Andy
 
 On Fri, Apr 2, 2010 at 10:55 AM, Michael Droettboom
 md...@stsci.edu mailto:md...@stsci.edu
 mailto:md...@stsci.edu mailto:md...@stsci.edu wrote:
 
Can you provide the actual saved profiler data?  The output
 of the
command itself doesn't provide enough information to diagnose the
problem, since it doesn't have full file paths etc.
 
When you do (thanks Gökhan for the less verbose version):
 
 python.exe -c import cProfile; cProfile.run('import pylab',
'test.out')
 
this should produce a binary file test.out that can be loaded
with the pstats module and used by GUI tools such as KCacheGrind
to help us get to the bottom of this.
 
Mike
 
Andrew Kelly wrote:
 
I'm back.
 
My backend is wx.  Import wx does not really take much time
to import at all.  In fact time.time() before and after = 0.0
 
Some computer details:
Processor: AMD Phenom IIx4 810 Processor 2.6 GHz
RAM: 8.00 GB
 
As for the cProfiler output on pylab, I have attached the
output as test.txt.
 -Andy
 
On Fri, Apr 2, 2010 at 7:22 AM, Gökhan Sever
gokhanse...@gmail.com mailto:gokhanse...@gmail.com
 mailto:gokhanse...@gmail.com mailto:gokhanse...@gmail.com
mailto:gokhanse...@gmail.com
 mailto:gokhanse...@gmail.com mailto:gokhanse...@gmail.com
 mailto:gokhanse...@gmail.com
 
wrote:
 
 
 
   On Fri, Apr 2, 2010 at 8:28 AM, Michael Droettboom
   md...@stsci.edu mailto:md...@stsci.edu
 mailto:md...@stsci.edu mailto:md...@stsci.edu
mailto:md...@stsci.edu mailto:md...@stsci.edu
 mailto:md...@stsci.edu mailto:md...@stsci.edu wrote:
 
   My gut says it's probably the GUI framework import
 that is
   dominating
   the time.  Which backend are you using?  Does
 importing it
   take a large
   amount of time as well?
 
   Can you provide a profiler output file we can examine
to narrow it
   down?  The following from a command prompt should be
   sufficient to write
   out a file called import.prof:
 
python.exe -c import cProfile;
 prof=cProfile.Profile();
   prof.run('import pylab', 'import.prof')
 
   Mike
 
 
   Just for the records,
 
   It reads as:
 
   python -c import cProfile; cProfile.run('import pylab',
   filename='test.out')
 
   in Python 2.6.2
 
   These helped me to load the profile output:
 
   import pstats
   stats = pstats.Stats(test.out)
   stats.print_stats()
 
   -- Gökhan
 

  
 --
   Download Intel#174; Parallel Studio Eval
   Try the new software tools for yourself. Speed compiling,
find bugs
   proactively, and 

[Matplotlib-users] Issues with Affine2D transform

2010-04-02 Thread Thomas Robitaille
Hi,

I have been trying to use the Affine2D transformation with pcolor and contour, 
with no success. The following script and comments illustrates my problems:

matplotlib.use('Agg')
import matplotlib.pyplot as mpl
from matplotlib.transforms import Affine2D
import numpy as np

image = np.random.random((100,100))

fig = mpl.figure()
ax = fig.add_subplot(1,1,1)
ax.pcolor(image, transform=Affine2D()) # Does not work - the image is not there!
fig.savefig('test1.png')

fig = mpl.figure()
ax = fig.add_subplot(1,1,1)
ax.contour(image, transform=Affine2D()) # Ok, but transformation wouldn't 
change anything anyway
fig.savefig('test2.png')

fig = mpl.figure()
ax = fig.add_subplot(1,1,1)
ax.contour(image, transform=Affine2D().scale(10.,10.)) # Does not work - the 
image is unchanged
fig.savefig('test3.png')

Is there a reason why transform doesn't work for contour and pcolor?

Thanks for any help,

Thomas
--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] visualizing colormaps for complex functions

2010-04-02 Thread Gary Ruben

Hi Guy,

I am also interested in the answer to this. The cplot function in the 
mpmath module does exactly this using matplotlib, but very 
inefficiently, as it computes the colour of each pixel in the image in 
hls colour-space and generates the corresponding rgb value directly. I 
suspect this is how it has to be done, as colormaps in matplotlib are 1D 
sequences and the black-white (lightness) value is really another 
dimension. However mpmath's method can be improved by doing the mapping 
using array operations instead of computing it for each pixel.


I've attached a function I wrote to reproduce the Sage cplot command in 
my own work. It's a bit old and can be improved. It takes the Arg and 
Abs of a complex array as the first two arguments - you can easily 
change this to compute these inside the function if you prefer. The line
np.vectorize(hls_to_rgb) can be replaced - recent versions of matplotlib 
have a vectorized function called hsv_to_rgb() inside colors.py - so you 
replace the return line with the commented-out version if you first 
import hsv_to_rgb from colors.


I hope this helps.

I'm also curious: the plots you point to also show plots of the function 
extrema, which are the phase singularities - does mathematica have a 
function that gives you these, or did you write your own function to 
find them?


regards,
Gary

Guy Rutenberg wrote:

Hi,

Is there a way to generate colormaps for complex-valued functions using 
matplotlib? The type of plots I'm looking for are like the plots in:

http://commons.wikimedia.org/wiki/User:Jan_Homann/Mathematics

Thanks in advance,

Guy
def cplot_like(ph, intens=None, int_exponent=1.0, s=1.0, l_bias=1.0, drape=0, 
is_like_mpmath=False):
'''
Implements the mpmath cplot-like default_color_function
The combined image is generated in hls colourspace then transformed to rgb
*phase*
A filename or 2D n x m array containing phase data in the range -pi-pi
*intens*
If None, set to 1.0
A filename or 2D n x m array containing intensity or amplitude data in 
the range 0-max
*int_exponent*
Default 1.0 applies the intens mask directly to the hls 
lightness-channel
0.6 works well when drape==0
*s*
saturation. Defaults to 1.0. mpmath uses 0.8.
*l_bias*
biases the mean lightness value away from 0.5. mpmath uses 1.0.
Examples are: l_bias=2 - mean=0.33 (ie darker), l_bias=0.5 - 
mean=0.66 (lighter)
*drape*
If 1, drapes a structured maximum filter of size drape x drape over 
the intensity data
*is_like_mpmath*
If True, sets int_exponent = 0.3, s = 0.8
'''
from colorsys import hls_to_rgb

if type(ph) is str:
cph = plt.imread(ph)/256.*2*pi-pi  # -pi-pi
if len(cph.shape) == 3: cph = cph[...,0]  # if ph is RGB or RGBA, 
extract the R-plane
else:
cph = ph.copy()

if intens is None:
cintens = np.ones_like(cph)
elif type(intens) is str:
cintens = plt.imread(intens)/255. # 0-1
if len(cintens.shape) == 3: cintens = cintens[...,0]   # if intens is 
RGB or RGBA, extract the R-plane
else:
cintens = intens.copy()
cintens /= cintens.max() # autoscale intensity data 
to 0-1

if drape  1:
# envelope the intensity
cintens = maximum_filter(cintens, size=drape)

h = ((cph + pi) / (2*pi)) % 1.0

if is_like_mpmath:
# apply mpmath values
int_exponent = 0.3
s = 0.8

l = 1.0 - l_bias/(l_bias+cintens**int_exponent)
v_hls_to_rgb = np.vectorize(hls_to_rgb)

#~ return hsv_to_rgb(dstack((h,np.ones_like(h),l)))
return dstack(v_hls_to_rgb(h,l,s))--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users