[matplotlib-devel] Bug(?) in FancyArrow overhang

2007-05-17 Thread Mark Bakker

Hello list -

I tried this on the user's list, but didn't get a response.
I am afraid it is a bug.
I am trying to use FancyArrow to draw an arrow with given length.
The length I use is from 0 to 100.
I specify length_includes_head=True.
This works fine when I specify a width and length.
But when I specify an overhang, the length of the arrow becomes much longer
than 100.
Am I using overhang incorrectly?
Here's a script with the problem:

from pylab import *
from matplotlib.patches import FancyArrow
axis([0,120,0,100])
ax = gca()
a = FancyArrow( 0, 40, 100, 0, length_includes_head=True, head_width=5,
head_length=5)
ax.add_patch(a)
b = FancyArrow( 0, 60, 100, 0, length_includes_head=True, head_width=5,
head_length=5, overhang=5)
ax.add_patch(b)
draw_if_interactive()

Thanks, Mark
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Bug(?) in FancyArrow overhang

2007-05-17 Thread John Hunter
On 5/17/07, Mark Bakker <[EMAIL PROTECTED]> wrote:

> I tried this on the user's list, but didn't get a response.
> I am afraid it is a bug.
> I am trying to use FancyArrow to draw an arrow with given length.
> The length I use is from 0 to 100.
> I specify length_includes_head=True.
> This works fine when I specify a width and length.
>  But when I specify an overhang, the length of the arrow becomes much longer
> than 100.
> Am I using overhang incorrectly?
> Here's a script with the problem:

FancyArrow was written by a colleague of Fernando -- perhaps you an
provide a free-standing script that illustrates the problem and
Fernando can pass it on to the original author to take a look.

JDH
>
> from pylab import *
> from matplotlib.patches import FancyArrow
> axis([0,120,0,100])
> ax = gca()
> a = FancyArrow( 0, 40, 100, 0, length_includes_head=True, head_width=5,
> head_length=5)
> ax.add_patch(a)
> b = FancyArrow( 0, 60, 100, 0, length_includes_head=True, head_width=5,
> head_length=5, overhang=5)
> ax.add_patch(b)
> draw_if_interactive()
>
> Thanks, Mark
>
> -
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> ___
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>
>

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] [Fwd: Re: [Numpy-discussion] [SciPy-user] median filter with clipping]

2007-05-17 Thread Eric Firing

Pierre,

I don't think John follows the numpy list closely, so I am forwarding this.

Eric
--- Begin Message ---
n Thursday 17 May 2007 04:54:22 Travis Oliphant wrote:
> I'm inclined to move his masked array over to ma wholesale.  The fact
> that Pierre sees it as his baby is very important to me. 

Well, all the credits should go to Paul Dubois, the original author of 
numpy.core.ma, and the scores of people who helped him. maskedarray would not 
have come to existence without them.

> If it doesn't 
> have significant compatibility issues than I'm all for it.  

None that I've seen so far. MaskedArrays created by one package can be read by 
the other. With a one-line editing of a file (numerix/ma/__init__.py), 
matplotlib runs seamlessly with the new package.
But once again, it is not completely bug-free: I just found a couple of bugs 
this week-end, or even yesterday, that were brought to my attention by Matt 
Knox when playing with the TimeSeries package. Nothing major, just some minor 
annoyances.

> I'm mainly 
> interested in hearing how people actually using numpy.ma would respond.

One issue is that maskedarray *is* slower than numpy.core.ma. If performance 
is preferred over flexibility, then one should stick to numpy.core.ma. Some 
basic estimations show about 15%.
I'd be quite interested in hearing about actual users of the packages, in 
order to find what points to implement/modify.

#--

On Thursday 17 May 2007 09:42:27 David Huard wrote:
> At the risk of offending Pierre's baby, I think that's a little premature.
> Not that maskedarray is not ready for general use on its own, but rather
> because subtle compatibility issues with numpy.ma may break matplotlib
> functions (I found one, and wouldn't be surprised to find others).

David, I wouldn't speak about compatibility, just about bugs: the problem was 
in the implementation of .max() w/ maskedarray. The origin of the problem was 
(is still) in umath.maximum.reduce that doesn't accept axis=None, so a numpy 
problem ;). But I agree: switching may have some subtle consequences in 
matplotlib (nothing that can't be quickly fiexed, however). What do Eric 
Firing, John Hunter and the other mpl developer think ?

My only request would be for more users ! That's the only way I can find how 
to improve maskedarray.
___
Numpy-discussion mailing list
[EMAIL PROTECTED]
http://projects.scipy.org/mailman/listinfo/numpy-discussion
--- End Message ---
-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] [Numpy-discussion] [SciPy-user] median filter with clipping

2007-05-17 Thread Eric Firing
Pierre GM wrote:
[...]
> 
> David, I wouldn't speak about compatibility, just about bugs: the problem was 
> in the implementation of .max() w/ maskedarray. The origin of the problem was 
> (is still) in umath.maximum.reduce that doesn't accept axis=None, so a numpy 
> problem ;). But I agree: switching may have some subtle consequences in 
> matplotlib (nothing that can't be quickly fiexed, however). What do Eric 
> Firing, John Hunter and the other mpl developer think ?

I think this would be a good time to make the switch.  We are going to 
be stripping out the Numeric and numarray support, so let's finalize the 
new ma capabilities at the same time.  I think that maskedarray is 
actually closer to being a drop-in replacement for ndarray than ma is, 
and I think it will be easier to work with.  I am confident that any 
problems can be solved easily.  A 15% speed penalty doesn't bother me; 
presumably it can be reduced later.

> 
> My only request would be for more users ! That's the only way I can find how 
> to improve maskedarray.

Moving maskedarray from the sandbox into svn numpy will make it easier 
for mpl devels to use it while doing and testing the mpl numpification.

(I won't be able to work on this until June.)

I suppose that it will be necessary for mpl to support both for a while, 
unfortunately, but I haven't thought this through carefully.

Eric


-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] unicode support for latex

2007-05-17 Thread Andrew Straw
Hi All (esp. Darren),

The attached patch adds unicode support for LaTeX. Given the recent
discussion about adding preambles, I thought I'd run it past here first.
Anyone opposed if I check this in?

Note that I specifically added the rcParam text.latex.unicode to enable
this and a default False value to turn this off by default. I hope this
prevents breakage for folks who don't have the ucs and inputenc latex
packages installed while allowing unicode for those of us that do.

-Andrew

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] unicode support for latex

2007-05-17 Thread Andrew Straw
OK, here's the patch! :)

Andrew Straw wrote:
> Hi All (esp. Darren),
>
> The attached patch adds unicode support for LaTeX. Given the recent
> discussion about adding preambles, I thought I'd run it past here first.
> Anyone opposed if I check this in?
>
> Note that I specifically added the rcParam text.latex.unicode to enable
> this and a default False value to turn this off by default. I hope this
> prevents breakage for folks who don't have the ucs and inputenc latex
> packages installed while allowing unicode for those of us that do.
>
> -Andrew
>
> -
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> ___
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>   

Index: CHANGELOG
===
--- CHANGELOG	(revision 3278)
+++ CHANGELOG	(working copy)
@@ -1,3 +1,7 @@
+2007-05-17 Added LaTeX unicode support. Enable with the
+   'text.latex.unicode' rcParam. This requires the ucs and
+   inputenc LaTeX packages. - ADS
+
 2007-04-23 Fixed some problems with polar -- dded general polygon
clipping to clip the lines a nd grids to the polar axes.
Added support for set_rmax to easily change the maximum
Index: lib/matplotlib/__init__.py
===
--- lib/matplotlib/__init__.py	(revision 3278)
+++ lib/matplotlib/__init__.py	(working copy)
@@ -775,6 +775,7 @@
 # text props
 'text.color': ['k', validate_color], # black
 'text.usetex'   : [False, validate_usetex],
+'text.latex.unicode': [False, validate_bool],
 'text.latex.preamble': ['', validate_latex_preamble],
 'text.dvipnghack': [False, validate_bool],
 'text.fontstyle': ['normal', str],
Index: lib/matplotlib/texmanager.py
===
--- lib/matplotlib/texmanager.py	(revision 3278)
+++ lib/matplotlib/texmanager.py	(working copy)
@@ -165,7 +165,8 @@
 def get_basefile(self, tex, fontsize, dpi=None):
 s = tex + self._fontconfig + ('%f'%fontsize) + self.get_custom_preamble()
 if dpi: s += ('%s'%dpi)
-return os.path.join(self.texcache, md5.md5(s).hexdigest())
+bytes = unicode(s).encode('utf-8') # make sure hash is consistent for all strings, regardless of encoding
+return os.path.join(self.texcache, md5.md5(bytes).hexdigest())
 
 def get_font_config(self):
 return self._fontconfig
@@ -197,17 +198,35 @@
'monospace'  : r'{\ttfamily %s}'}.get(self.font_family, 
  r'{\rmfamily %s}')
 tex = fontcmd % tex
+
+if rcParams['text.latex.unicode']:
+unicode_preamble = """\usepackage{ucs}
+\usepackage[utf8x]{inputenc}"""
+else:
+unicode_preamble = ''
 
 s = r"""\documentclass{article}
 %s
 %s
+%s
 \usepackage[papersize={72in,72in}, body={70in,70in}, margin={1in,1in}]{geometry}
 \pagestyle{empty}
 \begin{document}
 \fontsize{%f}{%f}%s
 \end{document}
-""" % (self._font_preamble, custom_preamble, fontsize, fontsize*1.25, tex)
-fh.write(s)
+""" % (self._font_preamble, custom_preamble, unicode_preamble,
+   fontsize, fontsize*1.25, tex)
+if rcParams['text.latex.unicode']:
+fh.write(s.encode('utf8'))
+else:
+try:
+fh.write(s)
+except UnicodeEncodeError, err:
+verbose.report("You are using unicode and latex, but have "
+   "not enabled the matplotlib 'text.latex.unicode' "
+   "rcParam.", 'helpful')
+raise
+
 fh.close()
 
 return texfile
Index: lib/matplotlib/backends/backend_ps.py
===
--- lib/matplotlib/backends/backend_ps.py	(revision 3278)
+++ lib/matplotlib/backends/backend_ps.py	(working copy)
@@ -1272,9 +1272,16 @@
 if orientation=='landscape': angle = 90
 else: angle = 0
 
-print >>latexh, r"""\documentclass{article}
+if rcParams['text.latex.unicode']:
+unicode_preamble = """\usepackage{ucs}
+\usepackage[utf8x]{inputenc}"""
+else:
+unicode_preamble = ''
+
+s = r"""\documentclass{article}
 %s
 %s
+%s
 \usepackage[dvips, papersize={%sin,%sin}, body={%sin,%sin}, margin={0in,0in}]{geometry}
 \usepackage{psfrag}
 \usepackage[dvips]{graphicx}
@@ -1288,8 +1295,21 @@
 \includegraphics*[angle=%s]{%s}
 \end{figure}
 \end{document}
-"""% (font_preamble, cu