Presently, there's no direct way to do this.  matplotlib uses the 
standard Python (derived from C) number formatting which uses a hyphen.  
There are a couple of workarounds, however.

You can set a custom tick formatter by providing a function and wrapping 
it in a FuncFormatter object.  (See attached).  You can have your 
function replace all of the hyphens with minus signs, or force it to use 
the mathtext formatting (which uses minus signs by default) by wrapping 
the text in '$'.  Alternatively, if your plot is designed for inclusion 
in t a (La)TeX document, you can turn usetex on in your matplotlibrc.

All that said, it might be nice to make this the default behavior in 
future versions of matplotlib.  We're about to make a release, so I 
don't want to put this in right now.  Could you possibly file a "Feature 
Request" in the tracker so we don't lose track of this?

Cheers,
Mike

Markus Kuhn wrote:
> Matplotlib currently uses the "hyphen" character instead of a "minus
> sign" when printing negative numbers in plots.
>
> While these two characters are traditionally not distinguished in
> monospaced fonts, there is a big difference in proportional fonts. A
> hyphen (Unicode character 0x002d) is very short and used between words,
> whereas a minus sign (Unicode: 0x2212) is much longer and looks exactly
> like the horizontal part of a plus sign.
>
> Practically all modern fonts do contain a minus sign. In those fonts
> that still lack a minus sign, the (often slightly lower/thinner/longer)
> "en dash" is usually a much less painful substitute than the hyphen.
> [The PostScript standard encoding lacks a minus sign, but the PostScript
> symbol font has one at 0x2d, as documented in
> http://www.unicode.org/Public/MAPPINGS/VENDORS/ADOBE/symbol.txt ]
>
> Example:
>
> from pylab import *
> plot([-3, -2, -1], [1,-3,-2])
> title(u"wrong: -2..+2   correct: \u22122..+2")
> show()
>
> Is there a way to cause matplotlib to use the correct minus-sign glyph?
> That would help to keep typographically very picky editors of scientific
> journals happy ...
>
> Markus
>
>   

-- 
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/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to