[Matplotlib-users] jagged edges on masked contour plots

2006-07-18 Thread John Pye
Hi all

I have an application requiring that I do contour plots for masked data.
At the edge of my contour plots, I'm getting fragmented contours due to
missing points on the corner of a cell in my grid.

Is there any way that the contour drawing code can be set up so that it
plots contours even if a cell in the grid only has data on two sides?

I suspect that the rule for contour plots is that no contours are shown
if *any* of the point on the four corners are missing.

There is an example with the jagged edge shown in the attached image.

Cheers
JP

-- 
John Pye
School of Mechanical and Manufacturing Engineering
The University of New South Wales
Sydney  NSW 2052  Australia
t +61 2 9385 5127
f +61 2 9663 1222
mailto:john.pye_AT_student_DOT_unsw.edu.au
http://pye.dyndns.org/


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


[Matplotlib-users] plot([0, 0], [1,2])

2006-07-18 Thread holger . dinkel

Hi Experts,

i just stumbled upon something i can't quite explain (or rather i think i can
explain it, but i cannot understand it):

Consider the following minimal example:

plot([1], [2],'o-'); show()

draws a single point at coords (1,2) - perfectly fine.

but when i try to plot the same at (0,2), i get an error:

plot([0], [2],'o-'); show()


/usr/lib/python2.4/site-packages/matplotlib/pylab.py in plot(*args, **kwargs)
   2016 hold(h)
   2017 try:
-> 2018 ret =  gca().plot(*args, **kwargs)
   2019 draw_if_interactive()
   2020 except:

/usr/lib/python2.4/site-packages/matplotlib/axes.py in plot(self, *args, 
**kwargs)
   2788 lines.append(line)
   2789 lines = [line for line in lines] # consume the generator
-> 2790 self.autoscale_view()
   2791 return lines
   2792

/usr/lib/python2.4/site-packages/matplotlib/axes.py in autoscale_view(self)
813
814 locator = self.xaxis.get_major_locator()
--> 815 self.set_xlim(locator.autoscale())
816 locator = self.yaxis.get_major_locator()
817 self.set_ylim(locator.autoscale())

/usr/lib/python2.4/site-packages/matplotlib/ticker.py in autoscale(self)
796 dmin, dmax = self.dataInterval.get_bounds()
797 dmin, dmax = self.nonsingular(dmin, dmax, expander = 0.05)
--> 798 return take(self.bin_boundaries(dmin, dmax), [0,-1])
799
800

/usr/lib/python2.4/site-packages/matplotlib/ticker.py in bin_boundaries(self, 
vmin, vmax)
766 def bin_boundaries(self, vmin, vmax):
767 nbins = self._nbins
--> 768 scale, offset = scale_range(vmin, vmax, nbins)
769 vmin -= offset
770 vmax -= offset

/usr/lib/python2.4/site-packages/matplotlib/ticker.py in scale_range(vmin, 
vmax, n, threshold)
731 dv = abs(vmax - vmin)
732 meanv = 0.5*(vmax+vmin)
--> 733 var = dv/max(abs(vmin), abs(vmax))
734 if var < 1e-12:
735 return 1.0, 0.0

ZeroDivisionError: float division


I assume this is becaus matplotlib is unable to figure out the width to which 
it should scale the plot...


Any idea how to fix this?

thanks in advance,


Holger


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


Re: [Matplotlib-users] basemap plots

2006-07-18 Thread Lionel Roubeyrie
HI,
how do you set the arrows on the bottom and the top of your colorbar? I don't 
find any option for that?
Thanks

Le Vendredi 07 Juillet 2006 10:11, [EMAIL PROTECTED] a écrit :
> On Friday 07 July 2006 4:11 pm, Lionel Roubeyrie wrote:
> > Hi all,
> > Is it possible to import colormap file from GMT (.cpt) to basemap?
> > If yes how can we do that?
> > Thanks
>
> It's possible. Here's how I've been doing it.
>
> (1) I use the gmtcolormapPylab function defined in:
> http://sourceforge.net/mailarchive/message.php?msg_id=11255878
>
> (2) Using the above function and a GMT cpt file (e.g.
> GMT_no_green.cpt), I set a color dictionary as:
> cdict = gmtcolormapPylab("GMT_no_green")
>
> (3) I define a colormap using:
> mycmap = cm.colors.LinearSegmentedColormap("GMT_no_green",cdict,256)
>
> (4) I apply the above using cmap=mycolormap in contourf or pcolormesh.
>
> By the way, in case you don't know of the following site, it has an
> exhaustive selection of color palettes: http://cpt-city.org.uk/
>
> I've also attached an example of a basemap image using a cpt from the
> above site. Masked values not defined by the colormap are shown in
> gray.

-- 
Lionel Roubeyrie - [EMAIL PROTECTED]
LIMAIR
http://www.limair.asso.fr

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


Re: [Matplotlib-users] plot([0, 0], [1,2])

2006-07-18 Thread Antonio Gonzalez
> but when i try to plot the same at (0,2), i get an error:
> 
> plot([0], [2],'o-'); show()

Well, this works perfectly fine for me (with mpl 0.87.4, rev 2558).
Maybe if you upgrade your mpl?

Cheers.

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


Re: [Matplotlib-users] Event handling for several windows

2006-07-18 Thread John Hunter
> "Tommy" == Tommy Grav <[EMAIL PROTECTED]> writes:

Tommy> I have a program that uses matplotlib to plot two images.
Tommy> figim24 = figure(figsize=(5,5)) figim70 =
Tommy> figure(figsize=(5,5))

Tommy> I want an event loop that will be able to register which of
Tommy> the two figures I mouse click in. When I only had one
Tommy> figure I used

Tommy> figim24.canvas.mpl_connect("button_press_event",clicker)

Tommy> but that obviously only register events in figim24. Can
Tommy> anyone guide me in the right direction for doing this?

You can either register two different callbacks (func1 and func2
below) or you can register both figures to the same callback (funcboth
below) and check which figure generated the event by inspecting the
figure.inaxes.figure attribute.  The latter approach only works if you
click over an axes,

from pylab import figure, show

fig1 = figure()
fig2 = figure()

ax1 = fig1.add_subplot(111)
ax2 = fig2.add_subplot(111)

def func1(event):
print 'func1'

def func2(event):
print 'func2'

def funcboth(event):
if event.inaxes is None: return
if event.inaxes.figure==fig1:
print 'funcboth: 1'
elif event.inaxes.figure==fig2:
print 'funcboth: 2'

fig1.canvas.mpl_connect('button_press_event', func1)
fig2.canvas.mpl_connect('button_press_event', func2)

fig1.canvas.mpl_connect('button_press_event', funcboth)
fig2.canvas.mpl_connect('button_press_event', funcboth)

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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] tick and axis label hiding

2006-07-18 Thread Michael Fitzgerald

Hi all,

I'm seeing some unexpected behavior when trying to hide a tick label,  
which I like to do with ganged plots.  When I attempt this, however,  
it seems the axis label is no longer drawn.  For example,

x = arange(5)
ax = subplot(111)
ax.plot(x, x)
xtl = ax.get_xticklabels()
xtl[0].set_visible(False)
ax.set_xlabel('foo')

will correctly not draw the leftmost x tick label, but it won't draw  
the axis label ('foo') either.  Subsequently issuing ax.get_xaxis 
().get_label().set_visible(True) doesn't help.  Any thoughts?

Mike



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


Re: [Matplotlib-users] tick and axis label hiding

2006-07-18 Thread John Hunter
> "Michael" == Michael Fitzgerald <[EMAIL PROTECTED]> writes:

Michael> Hi all,

Michael> I'm seeing some unexpected behavior when trying to hide a
Michael> tick label, which I like to do with ganged plots.  When I
Michael> attempt this, however, it seems the axis label is no
Michael> longer drawn.  For example,

Michael> x = arange(5) ax = subplot(111) ax.plot(x, x) xtl =
Michael> ax.get_xticklabels() xtl[0].set_visible(False)
Michael> ax.set_xlabel('foo')

Michael> will correctly not draw the leftmost x tick label, but it
Michael> won't draw the axis label ('foo') either.  Subsequently
Michael> issuing ax.get_xaxis ().get_label().set_visible(True)
Michael> doesn't help.  Any thoughts?

I just fixed this in svn -- the xlabel gets it's position by
examining the bounding boxes of all the tick labels, and wasn't
handling the invisible tick bounding box properly.  This is fixed in
svn.

Thanks for the report and example.
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Bug: y axis labels end up having multiple fonts. Example included

2006-07-18 Thread John Hunter
> "Vinj" == Vinj Vinj <[EMAIL PROTECTED]> writes:

Vinj> Some of the y axis labels end up having different fonts:
Vinj> http://s3.amazonaws.com/oylb/wlsn_qm.png?20060717232235

Vinj> In the above image, 7 and 7.5 have a larger font. I'm using
Vinj> matplotlib 0.87.3 with ubuntu

Bizarre.  Are you using usetex?  It doesn't look like it from the
fonts.  Does it help to flush the ttf cache in
~/.matplotlib/ttffont.cache?  Is it possible you are making a call to
set the fontsize somewhere and are just picking up selected elements?

I'll need to see some code to help debug this one.

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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] jagged edges on masked contour plots

2006-07-18 Thread Eric Firing
John,

You are correct about the way contour handles masked data, and I agree 
that it is ugly; unfortunately, it is inherent in the routine we are 
using.  You could reduce but not eliminate the problem by interpolating 
to a finer grid.

The routine we are using, which came from the gist package, has the 
virtues of an acceptable license, production of regular and filled 
contours, and handling of missing data (but with the problem you note, 
plus one bug that I have not been able to fix yet.)  I think it is also 
very efficient, although I have not done any benchmarking. If a better 
routine with the essential virtues could be found, we would probably use 
it; but I don't know of any.  In particular, open source routines that 
handle filled contours and masking seem to be very rare.

Eric

John Pye wrote:
> Hi all
> 
> I have an application requiring that I do contour plots for masked data.
> At the edge of my contour plots, I'm getting fragmented contours due to
> missing points on the corner of a cell in my grid.
> 
> Is there any way that the contour drawing code can be set up so that it
> plots contours even if a cell in the grid only has data on two sides?
> 
> I suspect that the rule for contour plots is that no contours are shown
> if *any* of the point on the four corners are missing.
> 
> There is an example with the jagged edge shown in the attached image.
> 
> Cheers
> JP
> 
> 
> 
> 
> 
> 
> 
> 
> -
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> 
> 
> 
> 
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


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


Re: [Matplotlib-users] basemap plots

2006-07-18 Thread Eric Firing
Lionel,

Assuming you have the current version of mpl, use the "extend" kwarg:

 colorbar properties:

 extend='neither', 'both', 'min', 'max'
 If not 'neither', make pointed end(s) for out-of-range
 values.  These are set for a given colormap using the
 colormap set_under and set_over methods.

If the colorbar is attached to a filled contour plot, however, you do 
not need to specify this kwarg in the colorbar call because it will be 
grabbed from the ContourSet object.

Eric


Lionel Roubeyrie wrote:
> HI,
> how do you set the arrows on the bottom and the top of your colorbar? I don't 
> find any option for that?
> Thanks
> 
> Le Vendredi 07 Juillet 2006 10:11, [EMAIL PROTECTED] a écrit :
> 
>>On Friday 07 July 2006 4:11 pm, Lionel Roubeyrie wrote:
>>
>>>Hi all,
>>>Is it possible to import colormap file from GMT (.cpt) to basemap?
>>>If yes how can we do that?
>>>Thanks
>>
>>It's possible. Here's how I've been doing it.
>>
>>(1) I use the gmtcolormapPylab function defined in:
>>http://sourceforge.net/mailarchive/message.php?msg_id=11255878
>>
>>(2) Using the above function and a GMT cpt file (e.g.
>>GMT_no_green.cpt), I set a color dictionary as:
>>cdict = gmtcolormapPylab("GMT_no_green")
>>
>>(3) I define a colormap using:
>>mycmap = cm.colors.LinearSegmentedColormap("GMT_no_green",cdict,256)
>>
>>(4) I apply the above using cmap=mycolormap in contourf or pcolormesh.
>>
>>By the way, in case you don't know of the following site, it has an
>>exhaustive selection of color palettes: http://cpt-city.org.uk/
>>
>>I've also attached an example of a basemap image using a cpt from the
>>above site. Masked values not defined by the colormap are shown in
>>gray.
> 
> 



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


[Matplotlib-users] No resizing of figures

2006-07-18 Thread Tommy Grav
Is there a keyword or a function to lock the figures so that they can not be resized?Cheers Tommy[EMAIL PROTECTED]http://homepage.mac.com/tgrav/"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genious -- and a lot of courage -- to move in the opposite direction"                         -- Albert Einstein -
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] No marker fill?

2006-07-18 Thread Michael Fitzgerald

Hi all,

I would like a way to set the marker face color to 'None' so that I  
may see overlapping markers.  I am aware of the workaround using  
scatter() to set alpha, but alas that's no good for PS output:

http://sourceforge.net/mailarchive/message.php?msg_id=12261949

Is this currently possible, or on the dev. radar?  If not, I'll file  
an official feature request.

Mike



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


Re: [Matplotlib-users] No marker fill?

2006-07-18 Thread John Hunter
> "Michael" == Michael Fitzgerald <[EMAIL PROTECTED]> writes:

Michael> Hi all,

Michael> I would like a way to set the marker face color to 'None'
Michael> so that I may see overlapping markers.  I am aware of the
Michael> workaround using scatter() to set alpha, but alas that's
Michael> no good for PS output:

Michael>http://sourceforge.net/mailarchive/message.php?msg_id=12261949

Michael> Is this currently possible, or on the dev. radar?  If
Michael> not, I'll file an official feature request.

You should be able to set the markerfacecolor property to 'None' the
string, as opposed to None, the python null object.  This is a bit
ugly, but None is used in the matplotlib properties to mean "do the
default, ie the rc setting".  If 

  plot(x, y, 'o', markerfacecolor='None')

fails, please post a complete example and we'll look into it.

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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] matplotlib with openoffice

2006-07-18 Thread Fabian Braennstroem
Hi,

since openoffice can use python as macro language, does
anyone know or has an idea, if is possible to use matplotlib
for plotting inside it. Would be nice to create diagrams
just be marking columns!?

Greetings!
 Fabian


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