[Matplotlib-users] saving data to a file

2007-01-02 Thread belinda thom
Hi,

Is there a way for me to keep adding the next row of a 2d array to a  
file via load? (matlab's save had a very useful -append option).

I managed to get 2d laod/save working, e.g.

   import numpy as N
   import pylab as P
   import bthom.utils as U
   # a numpy 2d array
   a = N.arange(12,dtype=N.float).reshape((3,4))
   a[0][0] = N.pi
   # checking out the matploblib save/load stuff
   P.save("data.csv", a, fmt="%.4f", delimiter=";")
   aa = P.load("data.csv", delimiter= ";")
   x,y,z,w = P.load("data.csv", delimiter=";", unpack=True)

The above took me longer than it perhaps should have b/c of advice  
I'd gotten elsewhere recommending trying to keep numpy and pylab  
separate when possible (to take advantage of all of numpy's features;  
it seems numpy doesn't even have the all-to-handy load/save  
functionality).

When I try similar tricks to write one row at a time, I'm hosed in  
that the shape is gone:

   # checking out a way to keep appending
   fname = "data1.csv"
   U.clobber_file(fname) #this thing just ensures 0 bytes in file
   f = open(fname,"a")
   nrows,ncols = a.shape
   for i in range(nrows) :
   P.save(f, a[i,:], fmt="%d", delimiter=";")
   f.close()
   aaa = P.load("data1.csv", delimiter= ";")

in particular:

   % cat data1.csv
   3
   1
   2
   4
   
   11

Thanks in advance,
--b





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


[Matplotlib-users] load_demo.py

2007-01-02 Thread belinda thom
Hi,

The documentation for pylab.load mentions the load_demo.py example.

I can't find this on my distribution. I believe all Pylab examples  
live in site-packages/doc/matplotlib, for in there are files like  
log_demo.py (the only file that begins with load is  
load_converter.py, which is demonstrating using dates).

Does anyone have access to load_demo.py or does it not exist (in  
which case the documentation for load should be modified)?

Thanks,

--b



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


Re: [Matplotlib-users] title and colorbar size

2007-01-02 Thread Eric Firing

John Hunter wrote:

"Petr" == Petr Danecek <[EMAIL PROTECTED]> writes:

[...]

Petr> 2) When set_aspect() is used, the size of colorbar does not
Petr> respect y-dimension of the graph. (See the attached
Petr> example.) Is it possible to set the size of the colorbar
Petr> directly?


Examples of the shrink kwarg are examples/image_masked.py and 
examples/contour_demo.py.


As an alternative to using the shrink kwarg you can always specify axes 
positions manually.  One example is in examples/multi_image.py. 
Attached is another example modified from image_masked.py.




One of the examples shows how to do this if I recall correctly, but I
don't remember which one.  Eric Firing wrote it so I'm sure he'll be
along shortly to point you to the light.  Eric -- perhaps we should
also add a snippet to the colorbar docstring since this is a common
request.


I have added a bit to the docstring to emphasize the function of the 
shrink kwarg.  This will usually be the easiest manual solution to the 
problem.  I have also thought a bit about adding functionality to the 
axes.draw() method that would allow the colorbar height to track the 
height of the mappable axes object; maybe I will try it later.


Eric
#!/usr/bin/env python
'''imshow with masked array input and out-of-range colors.

'''

from pylab import *
import matplotlib.numerix.ma as ma
import matplotlib.colors as colors


delta = 0.025
x = y= arange(-3.0, 3.0, delta)
X, Y = meshgrid(x, y)
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
Z = 10 * (Z2-Z1)  # difference of Gaussians

# Set up a colormap:
palette = cm.gray
palette.set_over('r', 1.0)
palette.set_under('g', 1.0)
palette.set_bad('b', 1.0)
# Alternatively, we could use
# palette.set_bad(alpha = 0.0)
# to make the bad region transparent.  This is the default.
# If you comment out all the palette.set* lines, you will see
# all the defaults; under and over will be colored with the
# first and last colors in the palette, respectively.
Zm = ma.masked_where(Z > 1.2, Z)

# By setting vmin and vmax in the norm, we establish the
# range to which the regular palette color scale is applied.
# Anything above that range is colored based on palette.set_over, etc.

fig = figure()
axi = fig.add_axes([0.1, 0.1, 0.7, 0.8])
im = axi.imshow(Zm, interpolation='bilinear',
cmap=palette,
norm = colors.Normalize(vmin = -1.0, vmax = 1.0, clip = False),
origin='lower', extent=[-3,3,-1,1])
title('Green=low, Red=high, Blue=bad')


axcb = fig.add_axes([0.85, 0.35, 0.02, 0.3])
fig.colorbar(im, cax=axcb, extend='both')
show()
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] title and colorbar size

2007-01-02 Thread John Hunter
> "Petr" == Petr Danecek <[EMAIL PROTECTED]> writes:

Petr> Hello, i'd like to ask two questions:

Petr> 1) Is it possible to control amount of space between title
Petr> and graph?

The y value of the title instance is in axes coordinates, so 1 is the
top of the axes, and numbers greater than 1 are further above the
top.  So you can do

t.set.y(1.1)

where t is the matplotlib.text.Text instance returned from pylab
'title' or from matplotlib.axes.Axes.set_title (both do the same
thing).

Alternatively, you can set the title instance properties from the axes
instance

ax = fig.add_subplot(111)
ax.title.set_y(1.1)

Petr> 2) When set_aspect() is used, the size of colorbar does not
Petr> respect y-dimension of the graph. (See the attached
Petr> example.) Is it possible to set the size of the colorbar
Petr> directly?

One of the examples shows how to do this if I recall correctly, but I
don't remember which one.  Eric Firing wrote it so I'm sure he'll be
along shortly to point you to the light.  Eric -- perhaps we should
also add a snippet to the colorbar docstring since this is a common
request.

JDH

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


Re: [Matplotlib-users] title and colorbar size

2007-01-02 Thread Jeff Whitaker
Petr Danecek wrote:
> Hello,
> i'd like to ask two questions:
>
> 1) Is it possible to control amount of space between title and graph?
>   

Petr:  The title command takes 'x' and 'y' keyword arguments that set 
the position of the title in axis coordinates.  For example, try 
'y=1.075' to move the title up a bit.
> 2) When set_aspect() is used, the size of colorbar does not respect
> y-dimension of the graph. (See the attached example.) Is it possible to
> set the size of the colorbar directly?
>   
I usually use the 'shrink' keyword to adjust the colorbar in situations 
like this.  You have to fiddle with it a bit to get the right value.  In 
your case, 'shrink=0.4' ought to do it. 

-Jeff


-- 
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC  R/PSD1FAX   : (303)497-6449
325 BroadwayBoulder, CO, USA 80305-3328


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


[Matplotlib-users] title and colorbar size

2007-01-02 Thread Petr Danecek
Hello,
i'd like to ask two questions:

1) Is it possible to control amount of space between title and graph?

2) When set_aspect() is used, the size of colorbar does not respect
y-dimension of the graph. (See the attached example.) Is it possible to
set the size of the colorbar directly?

Petr Danecek


test.png
Description: PNG image
from pylab import *
import os,sys,math

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

rc('figure',figsize=(3.346,3.346))

ax = subplot(111)
cs = ax.pcolor(X,Y,Z,shading='flat')
colorbar(cs)
title('Some title')

axis((0,2,0,1))
ax.set_aspect(1.0)

savefig('test.png',dpi=100)

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


Re: [Matplotlib-users] IDLE, matplotlib and show command

2007-01-02 Thread Giorgio Luciano
I've seen that it also works with
WxAgg version 2.8.0.1 for python 2.5
I hope this information can be useful
Giorgio


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