[Matplotlib-users] twinx doesn't keep xticks parameters

2008-01-17 Thread Lionel Roubeyrie
Hi,
all is in the subject:
#
ax=axes()
setp(ax.get_xticklabels(), rotation=30, fontsize=14)
twinx()

It's not really a problem because we can manually modify the xticks, but it 
would be great if it was done automatically.
Cheers

-- 
Lionel Roubeyrie - [EMAIL PROTECTED]
Chargé d'études et de maintenance
LIMAIR - la Surveillance de l'Air en Limousin
http://www.limair.asso.fr


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


Re: [Matplotlib-users] Is Gtk draw() slow?

2008-01-17 Thread Michael Droettboom


John Hunter wrote:
> On Jan 15, 2008 7:46 AM, Michael Droettboom <[EMAIL PROTECTED]> wrote:
>> Ah -- just thought of something else.
>>
>> If I adjust simple_plot_fps.py to have 100,000 data points rather than
>> 1,000 I see something that starts to match with what you're seeing:
>>
>> GtkAgg:
>> wallclock: 4.23297405243
>> user: 3.33
>> fps: 23.6240522057
>>
>> Gtk:
>> wallclock: 15.0203828812
>> user: 14.92
>> fps: 6.65761990165
>>
>> TkAgg:
>> wallclock: 4.8252530098
>> user: 4.67
>> fps: 20.7243018754
>>
>> You can see that the Gtk time is starting to explode.  If I go to
>> 1,000,000 points, Gtk runs out of memory before the first plot, whereas
>> the other two continue to chug along at a reasonable pace.
>>
>>  From looking at the code, I suspect the crucial difference is that the
>> Gdk backend uses the Python sequence API (rather slow) to access the
>> data as it gets rendered, whereas GtkAgg uses the numpy array interface
>> which is essentially raw access to a C array.
> 
> This is not likely to be the culprit -- for drawing markers, the old
> matplotlib API made a separate call to draw_polygon for every marker,
> with a new gc each time.  Many moons ago, we implemented draw_markers
> as a renderer method to avoid this problem.  For hundreds of thousands
> of markers, we saw performance benefits of 25x to 100x.  The backends
> which implement draw_markers (Agg and PS) get the benefits, but the
> other backends which did not are still slow. Basically it is a problem
> with a lot of redundant function call overhead.   The backend_bases
> renderer method _draw_markers discusses this a little bit (it is
> underscore hidden).

Markers are not the issue here.  These benchmarks were done with lines. 
  There are markers for the ticks, of course, but the number of those 
are fixed.  I agree it's function call overhead, but I believe it's in 
the overhead of PySequence_GetItem vs. array[index].  In both cases, the 
line is still getting drawn with a single Python -> C function call.

> My guess is this difference will not be so pronounced on the trunk.

Actually, I'm getting surprising results there.  Numbers are in fps.

Gtk GtkAgg  
0.91.2, 1000 points 50  26
0.91.2, 1 points6   23
trunk, 1000 points  38  31
trunk, 1 points 3   9

So, yes, the ratio between Gtk and GtkAgg on the trunk is not as 
pronounced.  I'm a little disappointed by the timings on the trunk -- 
while one could say that Agg is a little better on the trunk with 1000 
points, it doesn't scale nearly as well.  That's certainly something to 
look into -- and I don't have any thoughts offhand.  I would expect the 
trunk to do better since it doesn't perform a memory copy on the data 
with each call to draw_line/draw_path.

Cheers,
Mike

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

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


Re: [Matplotlib-users] Is Gtk draw() slow?

2008-01-17 Thread Michael Droettboom
Christopher Barker wrote:
> Michael Droettboom wrote:
>> It's sort of a pygtk issue -- it 
>> would have to be rewritten to take numpy arrays 
> 
> not quite -- it would have to be re-written to use the array interface, 
> which is different, as that can be done without requiring numpy, or its 
> headers.

Of course, that's what I meant.  It is passed numpy arrays now -- but 
they are accessed with all of the function call overhead of the Python 
sequence API, rather than the numpy array interface.

>  > which is probably
>> unlikely to happen in the official codebase.
> 
> That was true before the array interface, when supporting arrays 
> essentially meant a dependency on numpy. That's not longer true, so it's 
> quite likely that the pygtk folks would accept a patch -- someone still 
> would need to write that patch, though!

Unless I misunderstand, I thought that functionality was slated for 
inclusion in Python 3.0 -- still a long ways off in terms of adoption 
rate.  That patch would only make sense on a pygtk branch specifically 
intended for Python 3.0.

Cheers,
Mike

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

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


Re: [Matplotlib-users] multiline math text

2008-01-17 Thread Michael Droettboom
The subject line intrigues me, and hopefully I can help.  For whatever 
reason, the body of your message didn't make it to the mailing list. 
Can you please resend?

Cheers,
Mike

BL wrote:
> 
> 
> 
> 
> -
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> 
> 
> 
> 
> ___
> Matplotlib-users mailing list
> [email protected]
> 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

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


Re: [Matplotlib-users] TrueType font embedding in eps problem.

2008-01-17 Thread Michael Droettboom
There was a change between 0.90 to 0.91 as to how the TrueType to Type 
42 (which is essentially a thin wrapper around a TrueType font) 
conversion is done.  In 0.90 it was done in Python -- in 0.91 when font 
subsetting was added, this conversion is done in some borrowed C code 
called "ttconv".  That's just a guess as to what may be the specific 
cause.  I don't have a copy of Illustrator, so I haven't done any 
testing with that.  I'm happy to hear of a positive report from Rob. 
Perhaps you both (Rob and Jordan) are using different versions of 
Illustrator?

Note that ps.useafm essentially overrides the ps.fonttype setting.  If 
ps.useafm is True, you will always only get one of the 14 "builtin" 
Postscript fonts, which are not embedded in the file because all 
Postscript interpreters are required to support them.  If ps.useafm is 
False, then the other setting kicks in.  Type 42 essentially includes 
the whole Truetype font somewhat verbatim in the Ps file.  Type 3 will 
include only the used characters, using a format that is more native to 
Postscript.

All of them *should* be able to be editable on a purely theoretical 
level, though I would imagine Type 3 to be broken if you try to add a 
character that wasn't embedded in the file.  (This is different from how 
matplotlib does SVG font embedding where the original text really is 
lost).  But I don't really know what Illustrator's abilities and 
limitations are in that regard.

Hopefully Rob's suggestions will work for you.  Otherwise, I may want to 
revisit pulling the old Type 42 code back out of SVN to see if that 
solves your problem.  A good place to start might be if you could send 
me (off list) two eps files of the same plot -- one created with 0.90.1, 
and one with 0.91.2.

Cheers,
Mike

Rob Hetland wrote:
> There have been quite a few changes to fonts in MPL since 8.x.   
> Perhaps one of the biggest is mathtext.  Real unicode fonts with  
> mathematics.  Since you do what I do, sort of, I am guessing that you  
> might be happy with the same configuration I use.  I looks great, and  
> can be edited in Illustrator (et al.).
> 
> I really like Arev Sans, but others like the new STIX fonts.  This  
> setup is for Arev Sans.  The important stuff is what begins with  
> mathtext.  If you want serif fonts, this should be enough to get you  
> started on customizing.  Just make sure whatever fontset you pick has  
> all of the math symbols built in, or change fallback_to_cm to True.
> 
> -Rob
> 
> 
> font.family : sans-serif
> font.style  : normal
> font.variant: normal
> font.weight : medium
> font.stretch: normal
> font.size   : 12.0
> font.serif  : STIX, Bitstream Vera Serif, New Century  
> Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman,  
> Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
> font.sans-serif : Arev Sans
> font.cursive: Zapfino, Apple Chancery, Textile, Sand, cursive
> font.fantasy: Chicago, Comic Sans MS, Charcoal, Impact,  
> Western, fantasy
> font.monospace  : Bitstream Vera Sans Mono, Andale Mono, Nimbus  
> Mono L, Courier New, Courier, Fixed, Terminal, monospace
> 
> 
> text.color  : black
> text.usetex : False
> text.dvipnghack : True
> 
> mathtext.fallback_to_cm : False
> mathtext.fontset : custom
> 
> mathtext.cal : Arev Sans:oblique
> mathtext.it  : Arev Sans:oblique
> mathtext.rm  : Arev Sans
> mathtext.bf  : Arev Sans:bold
> mathtext.sf  : Arev Sans
> 
> pdf.fonttype   : 42
> 
> 
> 
> 
> 
> On Jan 16, 2008, at 10:13 PM, Jordan Dawe wrote:
> 
>> Setting ps.useafm = True while ps.fonttype = 42 allows illustrator to
>> open the eps files again and gives me back text editing capability,  
>> but
>> I don't have any control over the typeface anymore, it just  
>> defaults to
>> Helvetica.
>>
>> Jordan
>>
>> -- 
>> ---
>> This SF.net email is sponsored by: Microsoft
>> Defy all challenges. Microsoft(R) Visual Studio 2008.
>> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
>> ___
>> Matplotlib-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
> Rob Hetland, Associate Professor
> Dept. of Oceanography, Texas A&M University
> http://pong.tamu.edu/~rob
> phone: 979-458-0096, fax: 979-845-6331
> 
> 
> 
> -
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

-- 
Michael Droettboom
Science Software Branch
Operations and Eng

Re: [Matplotlib-users] Static linking problem on matplotlib eggs

2008-01-17 Thread Chris
I'm hoping someone can shed some light on this. I get the following error
when building on OSX. Notice that it looks into /usr/local for libraries:

/usr/local/include/ft2build.h:56:38:/usr/local/include/ft2build.h:56:38:
 error: error: freetype/config/ftheader.h: No such file or
directoryfreetype/config/ftheader.h: No such file or directory

Even though there is nothing that points there in my env:

MANPATH=/usr/share/man:/usr/local/share/man:/usr/X11/man
TERM=xterm-color
SHELL=/bin/bash
SSH_CLIENT=fe80::211:24ff:fe8d:9019%en1 57594 22
OLDPWD=/Users/chris/Development/freetype-2.3.5
LFLAGS=-arch ppc -arch i386 -L/Users/chris/Development/libpng-1.2.23
-L/Users/chris/Development/freetype-2.3.5
SSH_TTY=/dev/ttys001
USER=chris
PAGER=less
MAIL=/var/mail/chris
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:
/usr/local/bin:/usr/texbin
PWD=/Users/chris/Development/matplotlib
PS1=(\[$(tput md)\]\t <\w>\[$(tput me)\]) $(echo $?) \$
SHLVL=1
HOME=/Users/chris
CFLAGS=-arch ppc -arch i386 -I/Users/chris/Development/libpng-1.2.23
-I/Users/chris/Development/freetype-2.3.5
PYTHONPATH=/Library/Python/2.5/site-packages:
LESS=-r
LOGNAME=chris
SSH_CONNECTION=fe80::211:24ff:fe8d:9019%en1 57594
fe80::214:51ff:feef:bad8%en1 22
_=/usr/bin/env

Moreover, basedir['darwin'] is set to [] in setupext.py. 

So, I'm totally baffled. Where else could matplotlib be getting library path 
information from??

Thanks.




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


Re: [Matplotlib-users] Cross hair and polygon drawing tools.

2008-01-17 Thread Rob Hetland


I do this sort of stuff all of the time.  I have a tool that is  
interactive, making a polygon that you can edit (similar to  
poly_editor in the examples), that is linked to the polygeom class  
below, but it is broken in the new transforms release of the code.


poly_editor is also broken, by the way.  You can't insert a point  
anymore.


For now, you can use these simpler tools:

Good luck,

-Rob




from matplotlib.pyplot import *

class ginput(object):
"""docstring for on_click"""

def __init__(self):
self.x = []
self.y = []
connect('button_press_event', self)

def __call__(self, event):
xd, yd = event.xdata, event.ydata
if event.button==1:
if event.inaxes is not None:
# print 'data coords', event.xdata, event.ydata
self.x.append(xd)
self.y.append(yd)
plot((xd,), (yd,), 'r+', ms=5)

map_points = ginput()
#!/usr/bin/env python
# encoding: utf-8
"""Polygon geometry.

Copyright (C) 2006, Robert Hetland
Copyright (C) 2006, Stefan van der Walt

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the
   distribution.
3. The name of the author may not be used to endorse or promote
   products derived from this software without specific prior written
   permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
"""

import numpy as np
import sys

try:
import scipy.weave as weave

def npnpoly(verts,points):
verts = verts.astype(np.float64)
points = points.astype(np.float64)

xp = np.ascontiguousarray(verts[:,0])
yp = np.ascontiguousarray(verts[:,1])
x = np.ascontiguousarray(points[:,0])
y = np.ascontiguousarray(points[:,1])
out = np.empty(len(points),dtype=np.uint8)

code = """
/* Code from:
   http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

   Copyright (c) 1970-2003, Wm. Randolph Franklin

   Permission is hereby granted, free of charge, to any person
   obtaining a copy of this software and associated documentation
   files (the "Software"), to deal in the Software without
   restriction, including without limitation the rights to use, copy,
   modify, merge, publish, distribute, sublicense, and/or sell copies
   of the Software, and to permit persons to whom the Software is
   furnished to do so, subject to the following conditions:

	1. Redistributions of source code must retain the above
 copyright notice, this list of conditions and the following
 disclaimers.
	2. Redistributions in binary form must reproduce the above
 copyright notice in the documentation and/or other materials
 provided with the distribution.
	3. The name of W. Randolph Franklin may not be used to endorse
 or promote products derived from this Software without
 specific prior written permission. 

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   SOFTWARE. */
   
int i,j,n;
unsigned int c;
int nr_verts = Nxp[0];
for (n = 0; n < Nx[0]; n++) {
c = 0;
	for (i = 0, j = nr_verts-1; i < nr_verts; j = i++) {
if yp(i)<=y(n)) && (y(n)http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_N

Re: [Matplotlib-users] Bug in pylab?

2008-01-17 Thread Michael Droettboom
Darren Dale wrote:
> On Wednesday 16 January 2008 08:22:45 am Michael Droettboom wrote:
>> But reading Darren's new bug report makes me wonder if my fix was
>> correct.  To be honest, I'm a little confused by the bug report, not out
>> of any lack of clarity on Darren's part, but I think due to insufficient
>> understanding of the problem.  As assumption about the purpose of cla is
>>   that is should return the plot to a pristine state -- and in this case
>> that means linear axes.  But are you suggesting that sometimes that is
>> not the case?
> 
> If you have hold=True, and the x or y scale is log, repeated calls to plot() 
> will add new lines to the plot without changing the scaling. If hold is 
> instead False, one might reasonably expect that future calls to plot would 
> replace the old line with the new one, again without changing the scaling. 
> That would be consistent. Instead, the scaling changes.

That indeed is a problem.  I suspect it has something to do with the 
extra step that log scales do to "round" to the nearest decade.  I can 
have a look when I get a chance, or let me know if you'd like to tackle 
it, Darren.

Cheers,
Mike

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

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


Re: [Matplotlib-users] multiline mlath text

2008-01-17 Thread Michael Droettboom
There is no way to insert newlines in the mathtext part of the string 
(by that I mean between the '$').  However, you can put newline 
characters outside of '$'.  It gets a bit hairy because of Python's 
string escaping rules, but you could do something like:

   "$\\alpha=%G$\n$\\beta=%G$"

Note the double \\ where we really want a backslash, since we can't use 
"raw" string literals and write a newline character.

One other caveat: The spacing of the lines doesn't take into account the 
height of the math expression, so you can really only do simple 
one-liners (i.e. no fractions or exponents) in the math expression. 
Your example looks like it will work though.

This is really sort of "unsupported" and my example works only by 
accident...  it's something I didn't think about while re-writing 
mathtext recently.  Hopefully this can be improved in a future version 
-- I can see it as being generally useful.

Also -- for others on the list: Is there a TeX or LaTeX standard for 
putting newlines in the middle of a math expression that perhaps we 
should support?  All the Googling I've been able to do basically assumes 
that layout such as that would occur in a layer outside of the math 
expression (with the exception of typesetting things like matrices).

Cheers,
Mike

BL wrote:
>Hi,
> 
> I want to display the values of some variable (namely, alpha, beta, 
> gamma, delta) on a plot, and making a legend  like 
> "$ \alpha=%G, \  \bet=%G, \ \gamma=%G, \ \delta=%G $" % values is not 
> very readable. 
> Is there away to make multiline mathtext ?
> 
> 
> thanks
> 
> BL
> 
> 
> 
> 
> -
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> 
> 
> 
> 
> ___
> Matplotlib-users mailing list
> [email protected]
> 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

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


Re: [Matplotlib-users] Cross hair and polygon drawing tools.

2008-01-17 Thread Michael Droettboom
John Hunter wrote:
> On Jan 4, 2008 4:33 PM, Mephisto <[EMAIL PROTECTED]> wrote:
>> For some simple but effective Python code you can use to create a mask
>> similar to that provided by the Matlab roipoly function, see
>> http://www.ariel.com.au/a/python-point-int-poly.html
>> http://www.ariel.com.au/a/python-point-int-poly.html . The code seems to be
>> quite effective.
> 
> matplotlib implements these algorithms in C -- see
> matplotlib.nxutils.pnpoly for a testing inclusion of a single point,
> and matplotlib.nxutils.points_inside_poly for testing multiple points.
>  There is some example code using the latter function at
> http://matplotlib.sf.net/examples/lasso_demo.py.  Not sure why this
> example is not working for Venkat.

This is probably not the reason for Venkat (I think he said he was using 
0.87)... but lasso_demo.py is currently broken on the trunk, and working 
for me in 0.91.2.  I'm looking into it.

Cheers,
Mike

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

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


[Matplotlib-users] colorbar label every level

2008-01-17 Thread James Boyle
I am using the colorbar with a discrete set of intervals, the  
progression through the levels is not linear.
Presently, the colorbar call labels every other level, this looks  
very nice,  but unfortunately in my case one cannot infer the value  
of the unlabeled levels due to the non-linear scale.
Is there any easy way to force a label for every level ?
I am aware of the ticker - Locator, Formatter mechanism but I am  
looking for a very simple solution. If not I'll just do it.

Thanks for any help.

--Jim

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


Re: [Matplotlib-users] formatting axis to percent notation

2008-01-17 Thread Michael Droettboom
John Hunter wrote:
> On Jan 16, 2008 1:03 PM, Kevin Christman <[EMAIL PROTECTED]> wrote:
> def myfunc(x, pos=0):
> return '%1.2f''%(100*x)

And you may want to try:

def myfunc(x, pos=0):
 return '%1.2f%%''%(100*x)

to get a percent sign after each value.  (I mention it only because the 
"double percent" trick is non-obvious to many newcomers to Python's 
string formatting syntax.)

Cheers,
Mike

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

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


Re: [Matplotlib-users] TrueType font embedding in eps problem.

2008-01-17 Thread Rob Hetland

There have been quite a few changes to fonts in MPL since 8.x.   
Perhaps one of the biggest is mathtext.  Real unicode fonts with  
mathematics.  Since you do what I do, sort of, I am guessing that you  
might be happy with the same configuration I use.  I looks great, and  
can be edited in Illustrator (et al.).

I really like Arev Sans, but others like the new STIX fonts.  This  
setup is for Arev Sans.  The important stuff is what begins with  
mathtext.  If you want serif fonts, this should be enough to get you  
started on customizing.  Just make sure whatever fontset you pick has  
all of the math symbols built in, or change fallback_to_cm to True.

-Rob


font.family : sans-serif
font.style  : normal
font.variant: normal
font.weight : medium
font.stretch: normal
font.size   : 12.0
font.serif  : STIX, Bitstream Vera Serif, New Century  
Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman,  
Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
font.sans-serif : Arev Sans
font.cursive: Zapfino, Apple Chancery, Textile, Sand, cursive
font.fantasy: Chicago, Comic Sans MS, Charcoal, Impact,  
Western, fantasy
font.monospace  : Bitstream Vera Sans Mono, Andale Mono, Nimbus  
Mono L, Courier New, Courier, Fixed, Terminal, monospace


text.color  : black
text.usetex : False
text.dvipnghack : True

mathtext.fallback_to_cm : False
mathtext.fontset : custom

mathtext.cal : Arev Sans:oblique
mathtext.it  : Arev Sans:oblique
mathtext.rm  : Arev Sans
mathtext.bf  : Arev Sans:bold
mathtext.sf  : Arev Sans

pdf.fonttype   : 42





On Jan 16, 2008, at 10:13 PM, Jordan Dawe wrote:

> Setting ps.useafm = True while ps.fonttype = 42 allows illustrator to
> open the eps files again and gives me back text editing capability,  
> but
> I don't have any control over the typeface anymore, it just  
> defaults to
> Helvetica.
>
> Jordan
>
> -- 
> ---
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Rob Hetland, Associate Professor
Dept. of Oceanography, Texas A&M University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331



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


Re: [Matplotlib-users] multiline mlath text

2008-01-17 Thread Darren Dale
I dont think newlines are supported this way in tex. Here's an example:

\documentclass[]{article}

\begin{document}

$a=e^{i\pi}\\x=y$

$$a=e^{i\pi}\\x=y$$

\begin{eqnarray}
a & = & \frac{e^{i\pi}}{e^{-i\pi}} \\
  & = & e^{i2\pi}
\end{eqnarray}


\end{document}

The first treats the newline as if it occurred in regular text mode, the 
second ignores the newline entirely, and the third is intelligent enough to 
do what it should.


On Thursday 17 January 2008 08:51:06 am Michael Droettboom wrote:
> There is no way to insert newlines in the mathtext part of the string
> (by that I mean between the '$').  However, you can put newline
> characters outside of '$'.  It gets a bit hairy because of Python's
> string escaping rules, but you could do something like:
>
>"$\\alpha=%G$\n$\\beta=%G$"
>
> Note the double \\ where we really want a backslash, since we can't use
> "raw" string literals and write a newline character.
>
> One other caveat: The spacing of the lines doesn't take into account the
> height of the math expression, so you can really only do simple
> one-liners (i.e. no fractions or exponents) in the math expression.
> Your example looks like it will work though.
>
> This is really sort of "unsupported" and my example works only by
> accident...  it's something I didn't think about while re-writing
> mathtext recently.  Hopefully this can be improved in a future version
> -- I can see it as being generally useful.
>
> Also -- for others on the list: Is there a TeX or LaTeX standard for
> putting newlines in the middle of a math expression that perhaps we
> should support?  All the Googling I've been able to do basically assumes
> that layout such as that would occur in a layer outside of the math
> expression (with the exception of typesetting things like matrices).
>
> Cheers,
> Mike
>
> BL wrote:
> >Hi,
> >
> > I want to display the values of some variable (namely, alpha, beta,
> > gamma, delta) on a plot, and making a legend  like
> > "$ \alpha=%G, \  \bet=%G, \ \gamma=%G, \ \delta=%G $" % values is not
> > very readable.
> > Is there away to make multiline mathtext ?
> >
> >
> > thanks
> >
> > BL
> >
> >
> > 
> >
> > -
> > This SF.net email is sponsored by: Microsoft
> > Defy all challenges. Microsoft(R) Visual Studio 2008.
> > http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> >
> >
> > 
> >
> > ___
> > Matplotlib-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users



-- 
Darren S. Dale, Ph.D.
Staff Scientist
Cornell High Energy Synchrotron Source
Cornell University
275 Wilson Lab
Rt. 366 & Pine Tree Road
Ithaca, NY 14853

[EMAIL PROTECTED]
office: (607) 255-3819
fax: (607) 255-9001
http://www.chess.cornell.edu

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


Re: [Matplotlib-users] Is Gtk draw() slow?

2008-01-17 Thread Christopher Barker
Michael Droettboom wrote:
>> not quite -- it would have to be re-written to use the array 
>> interface, which is different, as that can be done without requiring 
>> numpy, or its headers.
> 
> Of course, that's what I meant.  It is passed numpy arrays now -- but 
> they are accessed with all of the function call overhead of the Python 
> sequence API, rather than the numpy array interface.

right, which is slow, slower than lists. In fact, it might make sense 
for MPL to convert to a list of tuples (using numpy) first, then pass 
that to pyGTK:

l = array.tolist()

It might speed things up a bit -- it did with wxPython a while back.

>> That was true before the array interface, when supporting arrays 
>> essentially meant a dependency on numpy. That's not longer true, so 
>> it's quite likely that the pygtk folks would accept a patch -- someone 
>> still would need to write that patch, though!
> 
> Unless I misunderstand, I thought that functionality was slated for 
> inclusion in Python 3.0 -- still a long ways off in terms of adoption 
> rate.  That patch would only make sense on a pygtk branch specifically 
> intended for Python 3.0.

The array interface is slated for be built-in for Py3k, but you can use 
it in the meantime. You just need to make sure your code understands it. 
PIL, for instance, uses it for its fromarray() and toarray() methods. 
Travis O. and others on the numpy list have been very helpful to folks 
trying to add it to their packages.

-Chris

-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

[EMAIL PROTECTED]

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


Re: [Matplotlib-users] Cross hair and polygon drawing tools.

2008-01-17 Thread Venkat Ramanan
Hi all,

Thanks for the helpful responses.

I had switched back to Matlab, meanwhile.

lasso_demo.py does look close to what I had wanted to implement. 
Earlier, while checking it out, I must have right-clicked first and 
after that it didn't seem to work ( perhaps a bug? ).

I'll look in to Rob's solution as well, once I upgrade to the latest 
release.

Thanks,
Venkat.


Michael Droettboom wrote:
> John Hunter wrote:
>   
>> On Jan 4, 2008 4:33 PM, Mephisto <[EMAIL PROTECTED]> wrote:
>> 
>>> For some simple but effective Python code you can use to create a mask
>>> similar to that provided by the Matlab roipoly function, see
>>> http://www.ariel.com.au/a/python-point-int-poly.html
>>> http://www.ariel.com.au/a/python-point-int-poly.html . The code seems to be
>>> quite effective.
>>>   
>> matplotlib implements these algorithms in C -- see
>> matplotlib.nxutils.pnpoly for a testing inclusion of a single point,
>> and matplotlib.nxutils.points_inside_poly for testing multiple points.
>>  There is some example code using the latter function at
>> http://matplotlib.sf.net/examples/lasso_demo.py.  Not sure why this
>> example is not working for Venkat.
>> 
>
> This is probably not the reason for Venkat (I think he said he was using 
> 0.87)... but lasso_demo.py is currently broken on the trunk, and working 
> for me in 0.91.2.  I'm looking into it.
>
> Cheers,
> Mike
>
>   


-- 
Venkat Ramanan,
Research Associate,
Imaging Research,
Sunnybrook Health Sciences Centre,
2075 Bayview Ave,
Toronto-M4N3M5
Ontario, Canada


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


Re: [Matplotlib-users] colorbar label every level

2008-01-17 Thread Eric Firing
James Boyle wrote:
> I am using the colorbar with a discrete set of intervals, the  
> progression through the levels is not linear.
> Presently, the colorbar call labels every other level, this looks  
> very nice,  but unfortunately in my case one cannot infer the value  
> of the unlabeled levels due to the non-linear scale.
> Is there any easy way to force a label for every level ?
> I am aware of the ticker - Locator, Formatter mechanism but I am  
> looking for a very simple solution. If not I'll just do it.

Jim,

Try the ticks=blist kwarg, where blist is the list of boundaries that 
you want labeled.

The ticks kwarg can specify either a sequence or a Locator; if no ticks 
kwarg is given then a default Locator is used.

Eric

> 
> Thanks for any help.
> 
> --Jim
> 
> -
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


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


Re: [Matplotlib-users] Is Gtk draw() slow?

2008-01-17 Thread Michael Droettboom
All very helpful information.  Thanks.

This is probably something to move to the pygtk list.  Personally, I don't 
consider it a high priority since the Gdk backend is limited in a number of 
other ways.  Maybe someone more motivated (who uses X remotely, for instance) 
wants to take the charge.  It would probably benefit more than just mpl.

Cheers,
Mike

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


[Matplotlib-users] Obtaining set_under and set_over colors

2008-01-17 Thread Carol Leger
Hi folks,

Is there a way to get the colors assigned with set_under and set over 
besides looking at _rgba_set_under and _rgba_set_over?

Sample code fragment:
from pylab import *
cmap = cm.get_cmap('jet')
cmap.set_over('wheat')

# Make some kind of polygon to fill
x = ...
y = ...
# Use the over-the-top color to fill the polygon
clrstr = rgb2hex(cmap._rgba_over[:3])
fill(x,y,clrstr)

-- 
Ms. Carol A. Leger
SRI International   Phone: (650) 859-4114
333 Ravenswood Avenue G-273
Menlo Park, CA 94025e-mail: [EMAIL PROTECTED]

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


[Matplotlib-users] help?

2008-01-17 Thread Jack Sankey
Hello,

I wrote a script that loops over some files, plotting them
individually with imshow(). In between each file, the program waits
for user input and then clears/closes the current figure before making
a new one.

Roughly 5-10 files into the loop, the script dies, outputting a loop
of stuff like this until I close the figure:

File "C:\Python25\Lib\site-packages\matplotlib\pyplot.py", line 201, in gcf
  File "C:\Python25\Lib\site-packages\matplotlib\pyplot.py", line 187, in figure
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wxagg.py",
line 120, in new_figure_manager
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wx.py",
line 1302, in __init__
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wxagg.py",
line 39, in _get_toolbar
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wx.py",
line 1593, in __init__
  File "C:\Python25\Lib\site-packages\matplotlib\backend_bases.py",
line 1391, in __init__
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wx.py",
line 1615, in _init_toolbar
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wx.py",
line 1452, in _load_bitmap
  File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py",
line 530, in __init__
PyAssertionError: C++ assertion "IsOpened()" failed at
..\..\src\common\ffile.cpp(187) in wxFFile::Seek(): can't seek on
closed file

Alternatively, it occasionally will tell me there are too many files
open. I have checked and all my file operations include a close(). Any
thoughts? I am using wxpython and wxAgg as my backend, with pycrust
(pyshell) on windows XP.

Thanks,
Jack

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


Re: [Matplotlib-users] help?

2008-01-17 Thread Jack Sankey
I also have another gui script where you move a slider around and it
changes the colormap, using

axes.images[0].set_cmap()
figure.canvas.Refresh()

in real time. It works wonderfully most of the time but occasionally
goes crazy, spouting a loop like this:

Traceback (most recent call last):
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wx.py",
line 1352, in _onClose
  File "C:\Python25\Lib\site-packages\matplotlib\_pylab_helpers.py",
line 28, in destroy
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wx.py",
line 1406, in destroy
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wx.py",
line 1365, in Destroy
  File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_core.py",
line 7198, in Yield
wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed at
..\..\src\msw\app.cpp(680) in wxApp::Yield(): wxYield called
recursively
Traceback (most recent call last):
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wx.py",
line , in _onSize
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wxagg.py",
line 61, in draw
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py",
line 380, in draw
  File "C:\Python25\Lib\site-packages\matplotlib\figure.py", line 612, in draw
  File "C:\Python25\lib\site-packages\matplotlib\axes.py", line 1344, in draw
  File "C:\Python25\Lib\site-packages\matplotlib\axis.py", line 596, in draw
  File "C:\Python25\Lib\site-packages\matplotlib\axis.py", line 170, in draw
  File "C:\Python25\Lib\site-packages\matplotlib\text.py", line 775, in draw
  File "C:\Python25\Lib\site-packages\matplotlib\text.py", line 317, in draw
  File "C:\Python25\Lib\site-packages\matplotlib\text.py", line 195,
in _get_layout
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py",
line 234, in get_text_width_height_descent
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py",
line 301, in _get_agg_font
RuntimeError: Could not open facefile c:\windows\fonts\vera.ttf;
Cannot_Open_Resource

I'm pretty lost about it :)

Thanks,
Jack

On Jan 17, 2008 6:03 PM, Jack Sankey <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I wrote a script that loops over some files, plotting them
> individually with imshow(). In between each file, the program waits
> for user input and then clears/closes the current figure before making
> a new one.
>
> Roughly 5-10 files into the loop, the script dies, outputting a loop
> of stuff like this until I close the figure:
>
> File "C:\Python25\Lib\site-packages\matplotlib\pyplot.py", line 201, in gcf
>   File "C:\Python25\Lib\site-packages\matplotlib\pyplot.py", line 187, in 
> figure
>   File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wxagg.py",
> line 120, in new_figure_manager
>   File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wx.py",
> line 1302, in __init__
>   File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wxagg.py",
> line 39, in _get_toolbar
>   File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wx.py",
> line 1593, in __init__
>   File "C:\Python25\Lib\site-packages\matplotlib\backend_bases.py",
> line 1391, in __init__
>   File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wx.py",
> line 1615, in _init_toolbar
>   File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_wx.py",
> line 1452, in _load_bitmap
>   File "C:\Python25\Lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py",
> line 530, in __init__
> PyAssertionError: C++ assertion "IsOpened()" failed at
> ..\..\src\common\ffile.cpp(187) in wxFFile::Seek(): can't seek on
> closed file
>
> Alternatively, it occasionally will tell me there are too many files
> open. I have checked and all my file operations include a close(). Any
> thoughts? I am using wxpython and wxAgg as my backend, with pycrust
> (pyshell) on windows XP.
>
> Thanks,
> Jack
>

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


Re: [Matplotlib-users] TrueType font embedding in eps problem.

2008-01-17 Thread Jordan Dawe
Rob Hetland wrote:
> I really like Arev Sans, but others like the new STIX fonts.  This 
> setup is for Arev Sans.  The important stuff is what begins with 
> mathtext.  If you want serif fonts, this should be enough to get you 
> started on customizing.  Just make sure whatever fontset you pick has 
> all of the math symbols built in, or change fallback_to_cm to True.
When I converted my matplotlibrc to the settings you listed, the result 
was pages and pages of exception tracebacks ending in:

C:\Python25\Lib\site-packages\matplotlib\mathtext.py in _get_font(self, 
font)
590 cached_font = self._fonts.get(basename)
591 if cached_font is None:
--> 592font = FT2Font(basename)
593cached_font = self.CachedFont(font)
594self._fonts[basename] = cached_font

If I remove all the LaTeX from my expressions, this error goes away.

Jordan

TypeError: cannot return std::string from Unicode object




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


Re: [Matplotlib-users] Obtaining set_under and set_over colors

2008-01-17 Thread Eric Firing
Carol Leger wrote:
> Hi folks,
> 
> Is there a way to get the colors assigned with set_under and set over 
> besides looking at _rgba_set_under and _rgba_set_over?
> 
> Sample code fragment:
> from pylab import *
> cmap = cm.get_cmap('jet')
> cmap.set_over('wheat')
> 
> # Make some kind of polygon to fill
> x = ...
> y = ...
> # Use the over-the-top color to fill the polygon
> clrstr = rgb2hex(cmap._rgba_over[:3])
> fill(x,y,clrstr)
> 

There is no better way at present.  I could add getters for these 
properties if there is sufficient need; it never occurred to me that 
anyone would need getters for them, and I did not want to clutter the API.

Did you resolve the problem you were having earlier with the colorbar 
diplay of the "under" value?

Eric

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