[Matplotlib-users] irregular grid of points: how to set figure pixel dimension ?

2007-09-24 Thread Emanuele Passera
Hi all,
I want to plot an irregular grid of points with x coordinates that can assume 
values between 0 and 13216 and  y coordinates that can assume values between 
0 and 8985 on a transparent canvas and save it as a .png file.
I use Agg backend.
I would like than to superimpose the obtained .png image over another image 
(not obtained with matplotlib and not with python) of 13217 x 8986 pixels.
This because the irregular grid points of the first image are pixels of the 
second image. 
I have write this script where 

samples = 13217 
lines = 8986 
dpi = 100
xvect and yvect 2 numpy vectors that i have to convert to lists.


# data aspect ratio
data_aspect_ratio = samples / float(lines)
# figure axis inches dimension
x_axis_inches = lines / float(dpi)
y_axis_inches = data_aspect_ratio * x_axis_inches
# drawing figure canvas
figure_label = p.figure(facecolor = 'w', edgecolor = 'w', 
figsize=(x_axis_inches, y_axis_inches), frameon = False)
# main axes enlarging to fill all vanvas
main_axes = p.axes([0, 0, 1, 1])
# plot grid
points_1 = p.plot(xvect.tolist(), yvect.tolist(), 'D')
# grid setting properties
p.setp(points_1, markersize = 30, markeredgecolor = 'b', markerfacecolor 
= 'None', markeredgewidth = 7)
main_axes.axis([0, lines, 0, samples])
# transparence
main_axes.axesPatch.set_alpha(0.0)
# deleting asix ticks
p.setp(main_axes, xticks = [], yticks = [])
# reversing y axis
y_reversing = main_axes.set_ylim(main_axes.get_ylim()[::-1])
# image saving
p.savefig(out_image_file, dpi = dpi)
# closing figure
p.close(figure_label)

The problem is that i obtain a .png image of 13216 x 8985 pixels and not of 
13217 x 8986 pixels as i planned. What can it be the problem ?
Thank you all.

-- 
--
Emanuele Passera

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] pcolor and masked arrays; am I missing something?

2007-09-24 Thread Mike Bauer
Howdy,

I'm a recent refugee from GMT (Generic Mapping Tools) and am very happy to
have found matplotlib.

I've been having one nagging issue however that I must resolve as I require
this ability. Basically, I need to mask 2d arrays and plot the result with
pcolor via basemap.

From the documentation it seems this should be fairly straight forward and
I'm hoping that this is the case.

Here is an example of problem.
---
from pylab import *
import matplotlib.numerix.ma as ma # matplotlibrc has numerix : numpy
from matplotlib.toolkits.basemap import Basemap, shiftgrid, addcyclic
import numpy as N
.
.
.

im = 144
jm = 93
lons  = N.array([0., ...  357.5],dtype=float)
lats =  N.array([-90., ... 90.],dtype=float)
topo_screen = N.zeros((jm,im),dtype='float')
topo_screen[10] = 1
new_test = 100.*N.ones((jm,im),dtype='float')
masked_test = ma.masked_where(topo_screen,new)

This works and a screen dump of masked_test seem correct.

A call to pcolor however results in the following:
matplotlib version 0.90.1
verbose.level helpful
interactive is False
units is True
platform is linux2
numerix numpy 1.0.1
.
.
.
/usr/local/lib/python2.5/site-packages/numpy/core/ma.py:604: UserWarning:
Cannot automatically convert masked array to numeric because data is masked
in one or more locations.
---

Is this an embarrassingly simple error on my part? I hope so. Any help would
be much appreciated.

Mike
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] pcolor and masked arrays; am I missing something?

2007-09-24 Thread Eric Firing
Mike,

pcolor has had masked array support for a long time.  Please send a 
minimal but complete example of a script that fails; based on what you 
sent below, I can't tell what the problem is.

Eric

Mike Bauer wrote:
 Howdy,
 
 I'm a recent refugee from GMT (Generic Mapping Tools) and am very happy 
 to have found matplotlib.
 
 I've been having one nagging issue however that I must resolve as I 
 require this ability. Basically, I need to mask 2d arrays and plot the 
 result with pcolor via basemap.
 
  From the documentation it seems this should be fairly straight forward 
 and I'm hoping that this is the case.
 
 Here is an example of problem.
 ---
 from pylab import *
 import matplotlib.numerix.ma http://matplotlib.numerix.ma as ma # 
 matplotlibrc has numerix : numpy
 from matplotlib.toolkits.basemap import Basemap, shiftgrid, addcyclic
 import numpy as N
 .
 .
 .
 
 im = 144
 jm = 93
 lons  = N.array([0., ...  357.5],dtype=float)
 lats =  N.array([-90., ... 90.],dtype=float)
 topo_screen = N.zeros((jm,im),dtype='float')
 topo_screen[10] = 1
 new_test = 100.* N.ones((jm,im),dtype='float')
 masked_test = ma.masked_where(topo_screen,new)
 
 This works and a screen dump of masked_test seem correct.
 
 A call to pcolor however results in the following:
 matplotlib version 0.90.1
 verbose.level helpful
 interactive is False
 units is True
 platform is linux2
 numerix numpy 1.0.1
 .
 .
 .
 /usr/local/lib/python2.5/site-packages/numpy/core/ma.py:604: 
 UserWarning: Cannot automatically convert masked array to numeric 
 because data is masked in one or more locations.
 ---
 
 Is this an embarrassingly simple error on my part? I hope so. Any help 
 would be much appreciated.
 
 Mike
 
 
 
 
 -
 This SF.net email is sponsored by: Microsoft
 Defy all challenges. Microsoft(R) Visual Studio 2005.
 http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
 
 
 
 
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] histogram question

2007-09-24 Thread Tommy Grav
I need to generate a set of histograms, but would like to plot only  
the skyline
of the histogram, and leave out the vertical lines where adjencent  
bars touch.
I have looked at the docs, but nothing jumped out at me as the right  
keyword
for this. Is this possible? and if so, how?

Cheers
   Tommy

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] histogram question

2007-09-24 Thread Perry Greenfield

On Sep 24, 2007, at 2:32 PM, Tommy Grav wrote:

 I need to generate a set of histograms, but would like to plot only
 the skyline
 of the histogram, and leave out the vertical lines where adjencent
 bars touch.
 I have looked at the docs, but nothing jumped out at me as the right
 keyword
 for this. Is this possible? and if so, how?

I believe that you can do the same thing using the regular plot  
command with linestyles='steps' (but I think you need to fiddle with  
the x values so that the steps are aligned properly. But it would be  
nice if hist could do this too.

Perry


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] histogram question

2007-09-24 Thread Matthew Auger
I wrote the following code to do this for me...it is not entirely general 
(in the sense that it doesn't accept all kwargs beyond bins and hatch) and 
also allows me to do my own normalization But you should be able to 
use it pretty easily.


def open_hist(arr,bins=10,norm=None,hatch=None):
 import matplotlib as mpl
 import pylab

 # Get all of the scaling right by allowing pylab to do it.
 d = pylab.hist(arr,bins)
 ax = pylab.gca()
 for i in d[2]:
 ax.patches.remove(i)
 width = d[1][1]-d[1][0]

 if norm is None:
 norm = 1.
 else:
 norm = float(norm)
 # Determine the vertices of the no-line histogram.
 verts = []
 for i in range(len(d[0])):
 if i==0:
 x = d[1][i]
 y = 0.
 verts.append((x,y))
 if i==len(d[0])-1:
 x = d[1][i]
 y = d[0][i]/norm
 verts.append((x,y))
 x = d[1][i]+width
 verts.append((x,y))
 y = 0.
 verts.append((x,y))
 else:
 x = d[1][i]
 y = d[0][i]/norm
 verts.append((x,y))
 x = d[1][i]+width
 verts.append((x,y))

 # Let pylab do its thing
 p = pylab.Polygon(verts,transform=ax.transData,hatch=hatch)
 p.set_fill(0)
 ax.add_patch(p)




On Mon, 24 Sep 2007, Tommy Grav wrote:

 I need to generate a set of histograms, but would like to plot only
 the skyline
 of the histogram, and leave out the vertical lines where adjencent
 bars touch.
 I have looked at the docs, but nothing jumped out at me as the right
 keyword
 for this. Is this possible? and if so, how?

 Cheers
   Tommy

 -
 This SF.net email is sponsored by: Microsoft
 Defy all challenges. Microsoft(R) Visual Studio 2005.
 http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] histogram question

2007-09-24 Thread Eric Firing
Perry Greenfield wrote:
 On Sep 24, 2007, at 2:32 PM, Tommy Grav wrote:
 
 I need to generate a set of histograms, but would like to plot only
 the skyline
 of the histogram, and leave out the vertical lines where adjencent
 bars touch.
 I have looked at the docs, but nothing jumped out at me as the right
 keyword
 for this. Is this possible? and if so, how?
 
 I believe that you can do the same thing using the regular plot  
 command with linestyles='steps' (but I think you need to fiddle with  
 the x values so that the steps are aligned properly. But it would be  
 nice if hist could do this too.

There is also an axes step() method in svn.

Eric

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] pcolor and masked arrays; am I missing something?

2007-09-24 Thread Mike Bauer
Howdy,

I'm a recent refugee from GMT (Generic Mapping Tools) and am very  
happy to have found matplotlib.

I've been having one nagging issue however that I must resolve as I  
require this ability. Basically, I need to mask 2d arrays and plot  
the result with pcolor via basemap.

 From the documentation it seems this should be fairly straight  
forward and I'm hoping that this is the case.

Here is an example of problem.
---
from pylab import *
import matplotlib.numerix.ma as ma # matplotlibrc has numerix : numpy
from matplotlib.toolkits.basemap import Basemap, shiftgrid, addcyclic
import numpy as N
.
.
.

im = 144
jm = 93
lons  = N.array([0., ...  357.5],dtype=float)
lats =  N.array([-90., ... 90.],dtype=float)
topo_screen = N.zeros((jm,im),dtype='float')
topo_screen[10] = 1
new_test = 100.*N.ones((jm,im),dtype='float')
masked_test = ma.masked_where(topo_screen,new)

This works and a screen dump of masked_test seem correct.

A call to pcolor however results in the following:
matplotlib version 0.90.1
verbose.level helpful
interactive is False
units is True
platform is linux2
numerix numpy 1.0.1
.
.
.
/usr/local/lib/python2.5/site-packages/numpy/core/ma.py:604:  
UserWarning: Cannot automatically convert masked array to numeric  
because data is masked in one or more locations.
---

Is this an embarrassingly simple error on my part? I hope so. Any  
help would be much appreciated.

Mike

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] error on build on windows from SVN

2007-09-24 Thread C M
I'm having problems building matplotlib on windows from a folder from SVN,
and haven't done it
before (previously had used the prebuilt binary download).  I don't know
what I am doing wrong.
I'm on winXP, Python 2.5. and will be using wxPython 2.8.4.2 with matplotlib
as well.

The folder with the contents from SVN I've named matplotlib_svn.  From the
cmd line and
while in that directory I wrote

python setup.py build

and got what follows.  I'm not sure what I am to do (regarding finding an
appropriate
compiler).  Any help is appreciated.


C:\Python25\Lib\site-packages\matplotlib_svnpython setup.py build

BUILDING MATPLOTLIB
matplotlib: 0.90.1
python: 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310
32 bit (Intel)]
  platform: win32
   Windows version: (5, 1, 2600, 2, 'Service Pack 2')

REQUIRED DEPENDENCIES
 numpy: 1.0
 freetype2: found, but unknown version (no pkg-config)
* WARNING: Could not find 'freetype2' headers in any
* of '.', '.\freetype2'.

OPTIONAL DEPENDENCIES
  Gtk+: no
* Building for Gtk+ requires pygtk; you must be able
* to import gtk in your build/install environment
   Tkinter: Tkinter: 50704, Tk: 8.4, Tcl: 8.4
* Tkinter present, but header files are not
* installed.  You may need to install development
* packages.
  wxPython: 2.8.4.2
* WxAgg extension not required for wxPython = 2.8
Qt: no
   Qt4: no
 Cairo: no
libpng: found, but unknown version (no pkg-config)
* Could not find 'libpng' headers in any of '.'

[Edit setup.cfg to suppress the above messages]

running build
running build_py
copying lib\matplotlib\mpl-data\matplotlibrc - build\lib.win32-
2.5\matplotlib\m
pl-data
running build_ext
No module named msvccompiler in numpy.distutils, trying from distutils..
error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible
binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin
installed,
you can try compiling with MingW32, by passing -c mingw32 to setup.py.
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] error on build on windows from SVN

2007-09-24 Thread John Hunter
On 9/24/07, C M [EMAIL PROTECTED] wrote:
 I'm having problems building matplotlib on windows from a folder from SVN,
 and haven't done it
 before (previously had used the prebuilt binary download).  I don't know
 what I am doing wrong.

Read the header of setupext.py, particularly the part for win32 users
-- it may not be totally current, but will get much you closer to your
 goal.  Once you have followed the steps there, if you hit another
roadblock check back here and  we will advise further and try and
update the docs as necessary.  You are actually in the best position
to write documentation, since you are hitting this for the first time,
so please take notes and/or update the instructions in setupext.py so
we can add them to the docs.

Thanks,
JDH

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] error on build on windows from SVN

2007-09-24 Thread C M
On 9/24/07, John Hunter [EMAIL PROTECTED] wrote:

 On 9/24/07, C M [EMAIL PROTECTED] wrote:
  I'm having problems building matplotlib on windows from a folder from
 SVN,
  and haven't done it
  before (previously had used the prebuilt binary download).  I don't know

  what I am doing wrong.

 Read the header of setupext.py, particularly the part for win32 users
 -- it may not be totally current, but will get much you closer to your
 goal.  Once you have followed the steps there, if you hit another
 roadblock check back here and  we will advise further and try and
 update the docs as necessary.  You are actually in the best position
 to write documentation, since you are hitting this for the first time,
 so please take notes and/or update the instructions in setupext.py so
 we can add them to the docs.


Well, not familiar with this at all but giving it a try...In the setupext.py
header it reads:

  This build is similar to the mingw.  Download the visual studio static
  dependencies from
  http://matplotlib.sourceforge.net/win32_static_vs.tar.gz and
  see the README in that dir

I did that.  Then, README there says:

  Contents:
  Static dependencies for building mpl for win32 using
  Visual Studio.
  Extract to the matplotlib source folder.

I extracted it to the matplotlib folder itself and also on another
try the subfolder, src.  In both cases then from cmd did:

  python setup.py build bdist_wininst

In both cases got same error as before.

I like to be more help but I am not sure what to do.
It isn't crucial that I get the latest via SVN and
build it myself, but I thought it would be good to learn
to do this generally, just didn't realize it would be a bit
of an expedition.  Not sure what to do.

Thanks.
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] etframes: Applying the ideas of Edward Tufte to matplotlib

2007-09-24 Thread Andrew Straw
I came across this piece by Adam Hupp on programming.reddit.com just 
now. It looks interesting:

http://hupp.org/adam/weblog/2007/09/03/etframes-applying-the-ideas-of-edward-tufte-to-matplotlib/
 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users