[Matplotlib-users] plotyy equivalent example -- png output

2010-04-29 Thread James Jack
Below is the working code to plot two different data series with different
units on the same graph, with the same x co-ordinates:



import pylab
# generate some data
x = range(0, 10)
y1 = [i*i for i in x]
y2 = [pylab.sin(0.4*i) for i in x]
# the data share x axis but have different y units

figure = pylab.gcf()   # Get the current figure
orig_axis = pylab.gca()# Get the current axis
orig_axis.set_axis_off()   # Turn it off to avoid complications
# use this for the overlapping axes
box = [0.14, 0.14, 0.72, 0.72]
# This uses the first set of data
axis1 = figure.add_axes(box, label = 'axis1')
axis1.set_title('TITLE')
axis1.plot(x, y1, '-^y')
axis1.set_ylabel('AXIS 1 LABEL')
axis1.set_xlabel('SHARED X LABEL')
axis1.spines['right'].set_visible(False)
# This uses the second set of data
# Note the same box region is used but the label must be different
axis2 = figure.add_axes(box, label = 'axis2')
axis2.plot(x, y2, '-sb')
axis2.yaxis.set_ticks_position('right')
axis2.yaxis.set_label_position('right')
axis2.set_ylabel('AXIS 2 LABEL')
axis2.spines['bottom'].set_visible(False)
axis2.spines['top'].set_visible(False)
axis2.spines['left'].set_visible(False)
# Write out to a file
pylab.savefig('out.png', dpi = 100, transparent = True)


Issues:

1) I can't use show() in this case because there is no Transparent
parameter.
2) It's still a botch.
3) I tried using alpha but it didn't seem to work at all?


Does anyone have a better implementation of this or better ideas?

Many thanks
James
--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotyy equivalent example -- png output

2010-04-29 Thread Matthias Michler
On Thursday 29 April 2010 15:02:34 James Jack wrote:
> Below is the working code to plot two different data series with different
> units on the same graph, with the same x co-ordinates:
>
>
>
> import pylab
> # generate some data
> x = range(0, 10)
> y1 = [i*i for i in x]
> y2 = [pylab.sin(0.4*i) for i in x]
> # the data share x axis but have different y units
>
> figure = pylab.gcf()   # Get the current figure
> orig_axis = pylab.gca()# Get the current axis
> orig_axis.set_axis_off()   # Turn it off to avoid complications
> # use this for the overlapping axes
> box = [0.14, 0.14, 0.72, 0.72]
> # This uses the first set of data
> axis1 = figure.add_axes(box, label = 'axis1')
> axis1.set_title('TITLE')
> axis1.plot(x, y1, '-^y')
> axis1.set_ylabel('AXIS 1 LABEL')
> axis1.set_xlabel('SHARED X LABEL')
> axis1.spines['right'].set_visible(False)
> # This uses the second set of data
> # Note the same box region is used but the label must be different
> axis2 = figure.add_axes(box, label = 'axis2')
> axis2.plot(x, y2, '-sb')
> axis2.yaxis.set_ticks_position('right')
> axis2.yaxis.set_label_position('right')
> axis2.set_ylabel('AXIS 2 LABEL')
> axis2.spines['bottom'].set_visible(False)
> axis2.spines['top'].set_visible(False)
> axis2.spines['left'].set_visible(False)
> # Write out to a file
> pylab.savefig('out.png', dpi = 100, transparent = True)
>
>
> Issues:
>
> 1) I can't use show() in this case because there is no Transparent
> parameter.
> 2) It's still a botch.
> 3) I tried using alpha but it didn't seem to work at all?
>
>
> Does anyone have a better implementation of this or better ideas?
>
> Many thanks
> James

Hi James,

I'm not sure I completely understand your problem, but for me it seems like 
the twinx-method of an Axes instance is what you need (see for instance: 
http://matplotlib.sourceforge.net/examples/api/two_scales.html)

for your example something like the following should work

import pylab
# generate some data
x = range(0, 10)
y1 = [i*i for i in x]
y2 = [pylab.sin(0.4*i) for i in x]
# the data share x axis but have different y units

figure = pylab.gcf()   # Get the current figure
box = [0.14, 0.14, 0.72, 0.72]
ax1 = figure.add_axes(box)
ax1.set_ylabel('axis1', color='b')
ax2 = ax1.twinx()
ax2.set_ylabel('axis2', color='g', )
ax1.plot(x, y1, '-^y', color='blue')
ax2.plot(x, y2, '-^y', color='green')

# Make the y-tick labels of first axes match the line color.
for tl in ax1.get_yticklabels():
tl.set_color('b')


pylab.show()

Kind regards,
Matthias

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotyy equivalent example -- png output

2010-04-29 Thread James Jack
Thank you Matthias :)

I think the problem here is that I never found an example showing 'twin'
scales, so I botched it to get the same result!

Cheers
James
--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Incompatibility with axvspan and legend on a semilog plot

2010-04-29 Thread Michael Droettboom
That is indeed a bug.  This has now been fixed in SVN r8288.  You can 
apply this patch to your local copy if you aren't running from SVN:


http://matplotlib.svn.sourceforge.net/viewvc/matplotlib?view=rev&revision=8288

Mike

On 04/28/2010 09:29 PM, Shrividya Ravi wrote:

Hi all,
I am having a problem having both a vspan and a legend in a figure 
plotted on a semilog axis. A simple code that gives the following 
error is shown in red:


ERROR

return self.frozen().__array__()
  File "/usr/lib/pymodules/python2.6/matplotlib/transforms.py", line 
1051, in __array__

return self.frozen().__array__()
  File "/usr/lib/pymodules/python2.6/matplotlib/transforms.py", line 
1706, in frozen

return blended_transform_factory(self._x.frozen(), self._y.frozen())
  File "/usr/lib/pymodules/python2.6/matplotlib/transforms.py", line 
1875, in frozen
frozen = composite_transform_factory(self._a.frozen(), 
self._b.frozen())
  File "/usr/lib/pymodules/python2.6/matplotlib/transforms.py", line 
1367, in frozen

return Affine2D(self.get_matrix().copy())
  File "/usr/lib/pymodules/python2.6/matplotlib/transforms.py", line 
1451, in __init__

Affine2DBase.__init__(self)
  File "/usr/lib/pymodules/python2.6/matplotlib/transforms.py", line 
1304, in __init__

Transform.__init__(self)
  File "/usr/lib/pymodules/python2.6/matplotlib/transforms.py", line 
87, in __init__

self._parents = WeakKeyDictionary()
  File "/usr/lib/python2.6/weakref.py", line 232, in __init__
def remove(k, selfref=ref(self)):
RuntimeError: maximum recursion depth exceeded while calling a Python 
object


CODE

x = numpy.arange(10,1e8,1000)
y = numpy.arange(0,100,0.001)

pylab.semilogx(x,y,'bo', label="Plot 1")

pylab.legend(loc='best')
pylab.axvspan(20,2e3,facecolor='k',alpha0.2)







--
   



___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
   


--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Colored bitmaps with MathTextParser

2010-04-29 Thread Michael Droettboom




I don't see this here (on the wx Buttons in the mathtext_wx.py example,
at least).  What are you using to display this bitmap?  It may be a
premultiplied/nonpremultiplied alpha problem.  Are you using the code I
attached, or setting the red channel to the text image as well?

Mike

On 04/29/2010 12:19 PM, Cédrick FAURY wrote:

  
  
Thank you for your answer, Mike.
  
It works fine, but I don't understand why there is grey points around 
the letters ... (see attached image)
  
  
Cédrick
  
Le 29/04/2010 15:17, Michael Droettboom a écrit :
  There
is
no direct way, but since you can get a numpy array of the text bitmap,
you can do whatever modifications you want to it.  For example, the
following is a modification of the mathtext_to_wxbitmap function in
mathtext_wx that takes an rgb tuple as an argument: 

def mathtext_to_wxbitmap(s, rgb): 
    ftimage, depth = mathtext_parser.parse(s, 150) 
    x = ftimage.as_array() 
    # Create an RGBA array for the destination, w x h x 4 
    rgba = np.zeros((x.shape[0], x.shape[1], 4), dtype=np.uint8) 
    # set the RGB components to the constant value passed in 
    rgba[:,:,0:3] = rgb 
    # set the A component to the shape of the text 
    rgba[:,:,3] = x 

    return wx.BitmapFromBufferRGBA( 
    ftimage.get_width(), ftimage.get_height(), 
    rgba.tostring()) 

Mike 

On 04/29/2010 02:28 AM, Cédrick FAURY wrote: 
Hello, 
  
Is it possible to get colored bitmaps (instead of black ones) with the 
MathTextParser when it is used as shown in the mathtext_wx.py example
?? 
  
Thanks by advance for your help. 
  
Best regards, 
Cédrick FAURY 
  
  
  
--

  
___ 
Matplotlib-users mailing list 
  Matplotlib-users@lists.sourceforge.net
  
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  
   


  
  




--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Is there any way *not* to embed fonts?

2010-04-29 Thread Ariel Rokem
Hi everyone,

Is there any way to get a svg output of a matplotlib, with the fonts not
embedded as vector graphic? That is, is there any way to make a figure, such
that a vector image editing program (such as Adobe Illustrator) would
recognize the text as text and would allow editing of the text, changing the
font and resizing the font size?

Cheers,

Ariel

-- 
Ariel Rokem
Helen Wills Neuroscience Institute
University of California, Berkeley
http://argentum.ucbso.berkeley.edu/ariel
--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Is there any way *not* to embed fonts?

2010-04-29 Thread Michael Droettboom

You can set the rcParam svg.embed_char_paths to False.

Mike

On 04/29/2010 01:43 PM, Ariel Rokem wrote:

Hi everyone,

Is there any way to get a svg output of a matplotlib, with the fonts 
not embedded as vector graphic? That is, is there any way to make a 
figure, such that a vector image editing program (such as Adobe 
Illustrator) would recognize the text as text and would allow editing 
of the text, changing the font and resizing the font size?


Cheers,

Ariel

--
Ariel Rokem
Helen Wills Neuroscience Institute
University of California, Berkeley
http://argentum.ucbso.berkeley.edu/ariel


--
   



___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
   


--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] MPL uses character not defined by cmr10?

2010-04-29 Thread Tony S Yu
There was a recent thread about the font sizes not matching up between regular text and math text. I decided I'd try to get matching font sizes by using computer modern as the default font, so I added the following to my matplotlibrc file:font.family: seriffont.serif: cmr10This fixes the font size issue, but for some reason, MPL's minus sign seems to be using a character not defined by the computer modern fonts (see y-axis in attached image).Is there a fix for this missing character?Best,-TonyP.S. I'm using the cmr10 fonts provided by MPL (confirmed by using the findfont function).--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] linestyles in LineCollection

2010-04-29 Thread Carlos Grohmann
Hi there

I found that the error is related to legend! If I disable

self.plotaxes.legend(bbox_to_anchor=(0.95, 0.95), loc=2,
prop=FontProperties(size='small'),numpoints=1)

I can change the linestyles and it works like a charm, but if I turn
on that line again... just errors.

can anyone think of something?

best

Carlos




On Wed, Apr 28, 2010 at 09:46, Michael Droettboom  wrote:
> I can't reproduce the error on 0.99.  Can you provide a complete script that
> reproduces the error?
>
> Mike
>
> Carlos Grohmann wrote:
>>
>> I've been trying to change the linestyles in a LineCollection, but
>> without any success...
>>
>> If I'm using:
>> col = collections.LineCollection(listXY, linewidths=circwdt,
>> colors=circcol, linestyle='solid', label=plabel)
>>
>> it works fine, but anything other than 'solid' gives me an error when
>> the code calls  FigureCanvasAgg.draw(self) (it is a wxpython app):
>>
>> Traceback (most recent call last):
>>  File "/home/guano/Arbeit/Stout/StereoPanel.py", line 552, in PlotChecked
>>    self.stereoCanvas.draw()
>>  File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_wxagg.py",
>> line 59, in draw
>>    FigureCanvasAgg.draw(self)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py",
>> line 314, in draw
>>    self.figure.draw(self.renderer)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46,
>> in draw_wrapper
>>    draw(artist, renderer, *kl)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 774, in
>> draw
>>    for a in self.axes: a.draw(renderer)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46,
>> in draw_wrapper
>>    draw(artist, renderer, *kl)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 1721, in
>> draw
>>    a.draw(renderer)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46,
>> in draw_wrapper
>>    draw(artist, renderer, *kl)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/legend.py", line 386, in
>> draw
>>    self._legend_box.draw(renderer)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 224, in
>> draw
>>    c.draw(renderer)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 224, in
>> draw
>>    c.draw(renderer)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 224, in
>> draw
>>    c.draw(renderer)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 224, in
>> draw
>>    c.draw(renderer)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/offsetbox.py", line 488, in
>> draw
>>    c.draw(renderer)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46,
>> in draw_wrapper
>>    draw(artist, renderer, *kl)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/lines.py", line 535, in
>> draw
>>    drawFunc(renderer, gc, tpath, affine.frozen())
>>  File "/usr/lib/pymodules/python2.6/matplotlib/lines.py", line 874,
>> in _draw_lines
>>    self._lineFunc(renderer, gc, path, trans)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/lines.py", line 925,
>> in _draw_dashed
>>    renderer.draw_path(gc, path, trans)
>>  File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py",
>> line 98, in draw
>> _path
>>    self._renderer.draw_path(gc, path, transform, rgbFace)
>> TypeError: float() argument must be a string or a number
>>
>>
>>
>> >From the MPL docs, I see that i should be able to use other linestyles:
>>
>>
>> http://matplotlib.sourceforge.net/api/collections_api.html#matplotlib.collections.LineCollection
>>
>> linestyles [ ‘solid’ | ‘dashed’ | ‘dashdot’ | ‘dotted’ ]
>> a string or dash tuple. The dash tuple is:
>>
>>
>>
>> I'm using MPL 0.99.0 in Ubuntu Karmic (9.10)
>>
>> tks
>>
>>
>>
>
> --
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
>
>



-- 
Prof. Carlos Henrique Grohmann - Geologist D.Sc.
Institute of Geosciences - Univ. of São Paulo, Brazil
http://www.igc.usp.br/pessoais/guano
Linux User #89721

Can’t stop the signal.

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] How to set constant y-axis scale value

2010-04-29 Thread melloncx

Hello,

I am quite new in matplotlib, I am now facing a quite simple problem but
have no idea to solve. I just want set the y axis scale to value 100, which
means in the image, the y axis is always of scale 100, because the points in
my image indicates the percentage value(for example, 20%, 87%) which will
never exceed 100.

So, How to set the y axis scale to constant value 100 ?? It's really hard to
find a answer from internet.
-- 
View this message in context: 
http://old.nabble.com/How-to-set-constant-y-axis-scale-value-tp28387748p28387748.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Horizontal and vertical lines between subplots

2010-04-29 Thread Maxime Bois

Hi all,

I have created a figure with 4 subplots (2x2) and I want to separate 
them with a vertical and horizontal lines (see the green lines on my 
figure edited by Gimp) but I don't know if it's possible (I haven't find 
any example of that).


I am using Python 2.5.4 and matplotlib version 0.99.0

Thanks,
Maxime
<>--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] [SPAM] PLEASE OPEN THIS ATTACHMENT AND HELP MY SON WHO IS IN DENGER

2010-04-29 Thread Mrs. Shirley Godwin


From Mrs. Shirley Godwin.pdf
Description: Binary data
--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Labels end up outside figure

2010-04-29 Thread acoffeemug

Hi,

I have tried to make a plot using the twinx() method to get different left
and right scales in the same plot.

The plot looks fine, but the y labels end up outside the figure. The same
problem can be seen in the example from the matplot homepage:

http://matplotlib.sourceforge.net/examples/api/two_scales.html

Here the y labels 'exp' and 'sin' are outside the plot.

Does anyone know a good fix for this? Preferably one which doesn't involve
manual resizing?

I use ipython with -pylab to generate the plots.

Best regards,
Jóan Petur
-- 
View this message in context: 
http://old.nabble.com/Labels-end-up-outside-figure-tp28402985p28402985.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to set constant y-axis scale value

2010-04-29 Thread Eric Firing
melloncx wrote:
> Hello,
> 
> I am quite new in matplotlib, I am now facing a quite simple problem but
> have no idea to solve. I just want set the y axis scale to value 100, which
> means in the image, the y axis is always of scale 100, because the points in
> my image indicates the percentage value(for example, 20%, 87%) which will
> never exceed 100.
> 
> So, How to set the y axis scale to constant value 100 ?? It's really hard to
> find a answer from internet.

If you are using the pyplot interface, then maybe what you want is the 
ylim function:

http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.ylim

Eric

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] MPL uses character not defined by cmr10?

2010-04-29 Thread Michael Droettboom




Those Computer Modern fonts (specifically the Bakoma distribution of
them that matplotlib includes) use a custom character set mapping where
many of the characters are in completely arbitrary locations.  For
regular text, matplotlib expects a regular Unicode font (particularly
to get the minus sign).  Since cmr10 doesn't have a standard encoding,
it just won't work.  

You could get around this by overriding the default formatter to use a
different symbol for the minus sign.  See this example for an example
of overriding the formatter:

http://matplotlib.sourceforge.net/examples/pylab_examples/major_minor_demo1.html#pylab-examples-major-minor-demo1

Mike

On 04/29/2010 03:33 PM, Tony S Yu wrote:

  There was a recent thread
about the font sizes not matching up between regular text and math
text. I decided I'd try to get matching font sizes by using computer
modern as the default font, so I added the following to my matplotlibrc
file:
  
  
  
  font.family: serif
  font.serif: cmr10
  
  
  
  This fixes the font size issue, but for some reason, MPL's minus
sign seems to be using a character not defined by the computer modern
fonts (see y-axis in attached image).
  
  
  Is there a fix for this missing character?
  
  
  Best,
  -Tony
  
  
  P.S. I'm using the cmr10 fonts provided by MPL (confirmed by
using the findfont function).
  
  
  
  

--
  
  

___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  




--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] How to set constant y-axis scale value

2010-04-29 Thread PHobson
> -Original Message-
> From: melons [mailto:xic...@cc.hut.fi]
> Sent: Wednesday, April 28, 2010 5:14 AM
> To: matplotlib-users@lists.sourceforge.net
> Subject: [Matplotlib-users] How to set constant y-axis scale value
> 
> 
> Hello,
> 
> I am quite new in matplotlib, I am now facing a quite simple problem but
> have no idea to solve. I just want set the y axis scale to value 100,
> which
> means in the image, the y axis is always of scale 100, because the points
> in
> my image indicates the percentage value(for example, 20%, 87%) which will
> never exceed 100.
> 
> So, How to set the y axis scale to constant value 100 ?? It's really hard
> to
> find a answer from internet.

Give this a shot:
# 
import matplotlib.pyplot as plt
import numpy as np

x = np.arange(20)
y = np.random.randn(20)
y = y/y.max() * 100

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x,y,'ko', mfc='none')

# you can do this:
ax.set_ylim([0,100])

# or something like this:
ax.set_ylim(ymin=0, ymax=100)
plt.show()


--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] MPL uses character not defined by cmr10?

2010-04-29 Thread Tony S Yu

On Apr 29, 2010, at 10:43 PM, Tony S Yu wrote:

> 
> On Apr 29, 2010, at 6:09 PM, Michael Droettboom wrote:
> 
>> Those Computer Modern fonts (specifically the Bakoma distribution of them 
>> that matplotlib includes) use a custom character set mapping where many of 
>> the characters are in completely arbitrary locations.  For regular text, 
>> matplotlib expects a regular Unicode font (particularly to get the minus 
>> sign).  Since cmr10 doesn't have a standard encoding, it just won't work.  
> 
> 
> Hey Mike,
> 
> Thanks for your reply. That makes sense.
> 
> An alternative work around (I presume) would be to install the computer 
> modern unicode fonts (I made sure to install the ttf version). However, I'm 
> having trouble getting MPL to find the fonts.
> 
> The installed font is listed when calling 
> `mpl.font_manager.OSXInstalledFonts()`, but it's not found when calling 
> `mpl.font_manager.findfont` (with various names that would make sense: 
> cmunrm, CMU Serif, etc.)
> 
> Any ideas on what I'm doing wrong?

Sorry, I meant to reply to the list.

After clearing the fontlist cache, I was able to get this fix working.

Just to summarize:

* download unicode version of computer modern fonts 
(http://sourceforge.net/projects/cm-unicode/files/)---make sure to get the ttf 
version

* clear out the fontlist cache (rm ~/.matplotlib/fontList.cache)

* add the following to ~/matplotlib/matplotlibrc:

font.family: serif
font.serif: CMU Serif

* alternatively, you could leave the default as sans serif and use the computer 
modern sans serif (unicode version):

font.sans-serif: CMU Sans Serif

These changes produce plots where the size of normal text matches that of 
mathtext.

Thanks for you help, Mike!

-Tony

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] MPL uses character not defined by cmr10?

2010-04-29 Thread Tony S Yu

On Apr 29, 2010, at 11:51 PM, Tony S Yu wrote:

> 
> On Apr 29, 2010, at 10:43 PM, Tony S Yu wrote:
> 
>> 
>> On Apr 29, 2010, at 6:09 PM, Michael Droettboom wrote:
>> 
>>> Those Computer Modern fonts (specifically the Bakoma distribution of them 
>>> that matplotlib includes) use a custom character set mapping where many of 
>>> the characters are in completely arbitrary locations.  For regular text, 
>>> matplotlib expects a regular Unicode font (particularly to get the minus 
>>> sign).  Since cmr10 doesn't have a standard encoding, it just won't work.  
>> 
>> 
>> Hey Mike,
>> 
>> Thanks for your reply. That makes sense.
>> 
>> An alternative work around (I presume) would be to install the computer 
>> modern unicode fonts (I made sure to install the ttf version). However, I'm 
>> having trouble getting MPL to find the fonts.
>> 
>> The installed font is listed when calling 
>> `mpl.font_manager.OSXInstalledFonts()`, but it's not found when calling 
>> `mpl.font_manager.findfont` (with various names that would make sense: 
>> cmunrm, CMU Serif, etc.)
>> 
>> Any ideas on what I'm doing wrong?
> 
> Sorry, I meant to reply to the list.
> 
> After clearing the fontlist cache, I was able to get this fix working.
> 
> Just to summarize:
> 
> * download unicode version of computer modern fonts 
> (http://sourceforge.net/projects/cm-unicode/files/)---make sure to get the 
> ttf version
> 
> * clear out the fontlist cache (rm ~/.matplotlib/fontList.cache)
> 
> * add the following to ~/matplotlib/matplotlibrc:
> 
> font.family: serif
> font.serif: CMU Serif
> 
> * alternatively, you could leave the default as sans serif and use the 
> computer modern sans serif (unicode version):
> 
> font.sans-serif: CMU Sans Serif
> 
> These changes produce plots where the size of normal text matches that of 
> mathtext.
> 
> Thanks for you help, Mike!
> 
> -Tony
> 

Umm, ... last email on this topic, I promise.

Is there any reason the font family rc parameter is case sensitive, while the 
findfont input is case insensitive? In other words, replacing

> font.serif: CMU Serif

with

> font.serif: cmu serif

does not work. On the other hand, both of the following work:

>>> mpl.font_manager.findfont('cmu serif')
>>> mpl.font_manager.findfont('CMU Serif')

This caused me problems when debugging my earlier font troubles.

Best,
-Tony

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users