number rendering in GTKCairo

Hello all,

I am trying to get a setup where I can have an interactive environment and output to PDF files as needed. I currently have this setup working in OS X 10.5 without problems. However, I cannot get a similar setup working on linux. The best I have been able to do is by using GTKCairo but it has a problem with rendering numbers in math mode. Specifically when I put a number, say "-3.1415", into a string the decimal is converted to a : and the "-" is turned into an "i". Below is an example that gives this error:
import numpy
from pylab import *
x = numpy.arange(1,100,1)
e1=-1.8
e2=-2.1
y = x**2
z = x**-2
f = figure(num=1)
f.clear()
ax = f.add_subplot(111)
p = ax.plot(x,y)
p1 = ax.plot(x,z)
title('This works -2.1 but this doesnot $-2.1$')
legend((p[0],p1[0]),(r'$x^{%.2g}$'%(e1),r'$x^{%.2g}$'%(e2)))
draw()
savefig('test.pdf')

The output looks fine in GTKAgg but then I get an error on glib.

Anyone have any ideas on how to get it working?

Regards,
Brian

It works for me on Linux with matplotlib 0.91.1, and Cairo 1.4.0.

What version of matplotlib and Cairo are you using? It sounds like it may be pulling in the wrong fonts. Can you please send the contents of your matplotlibrc file, and also set "verbose.level" to "debug-annoying" and send the output?

Cheers,
Mike

Brian Baughman wrote:

···

Hello all,

I am trying to get a setup where I can have an interactive environment and output to PDF files as needed. I currently have this setup working in OS X 10.5 without problems. However, I cannot get a similar setup working on linux. The best I have been able to do is by using GTKCairo but it has a problem with rendering numbers in math mode. Specifically when I put a number, say "-3.1415", into a string the decimal is converted to a : and the "-" is turned into an "i". Below is an example that gives this error:
import numpy
from pylab import *
x = numpy.arange(1,100,1)
e1=-1.8
e2=-2.1
y = x**2
z = x**-2
f = figure(num=1)
f.clear()
ax = f.add_subplot(111)
p = ax.plot(x,y)
p1 = ax.plot(x,z)
title('This works -2.1 but this doesnot $-2.1$')
legend((p[0],p1[0]),(r'$x^{%.2g}$'%(e1),r'$x^{%.2g}$'%(e2)))
draw()
savefig('test.pdf')

The output looks fine in GTKAgg but then I get an error on glib.

Anyone have any ideas on how to get it working?

Regards,
Brian

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell. From the desktop to the data center, Linux is going
mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
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

Hello,

I am using matplotlib svn 4626 and Cairo 1.4.0 all with python 2.5 with Ubuntu linux 7.10. The only lines in my matplotlibrc file which are uncommented are:
backend : GTKCairo
numerix : numpy # numpy, Numeric or numarray
interactive : True # see http://matplotlib.sourceforge.net/interactive.html
verbose.level : debug-annoying # one of silent, helpful, debug, debug-annoying

Below is the output of the script I submitted when debug-annoying is turned on:
In [3]: x = numpy.arange(1,100,1)

In [4]: e1=-1.8

In [5]: e2=-2.1

In [6]: y = x**2

In [7]: z = x**-2

In [8]: f = figure(num=1)

In [9]: f.clear()

In [10]: ax = f.add_subplot(111)

In [11]: p = ax.plot(x,y)

In [12]: p1 = ax.plot(x,z)

In [13]: title('This works -2.1 but this doesnot $-2.1$')
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
Out[13]: <matplotlib.text.Text instance at 0x8be1e8c>

In [14]: legend((p[0],p1[0]),(r'$x^{%.2g}$'%(e1),r'$x^{%.2g}$'%(e2)))
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
Out[14]: <matplotlib.legend.Legend instance at 0x906f5ac>

In [15]: draw()
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
  findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf

It looks like it is finding the fonts in 2.4 when I am using 2.5. I am not sure how to change this behavior nor why that would be the only side effect.

Regards,
Brian

···

On Dec 5, 2007, at 1:36 PM, Michael Droettboom wrote:

It works for me on Linux with matplotlib 0.91.1, and Cairo 1.4.0.

What version of matplotlib and Cairo are you using? It sounds like it may be pulling in the wrong fonts. Can you please send the contents of your matplotlibrc file, and also set "verbose.level" to "debug-annoying" and send the output?

Cheers,
Mike

What's happening is that it isn't finding the Bakoma Computer Modern fonts. These have a non-standard encoding, so the '-' for instance, is actually under a different character code.

So... we need to track down why it's looking in the wrong place.

Can you send the output of:

> python
Python 2.5.1 (r251:54863, Jul 2 2007, 08:53:40)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__file__
'/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/__init__.pyc'
>>> matplotlib.__version__
'0.91.2.svn'
>>> matplotlib._get_data_path()
'/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/mpl-data'
>>>

You may also try deleting your font cache in ~/.matplotlib/fontManager.cache

Cheers,
Mike

Brian Baughman wrote:

···

Hello,

I am using matplotlib svn 4626 and Cairo 1.4.0 all with python 2.5 with Ubuntu linux 7.10. The only lines in my matplotlibrc file which are uncommented are:
backend : GTKCairo
numerix : numpy # numpy, Numeric or numarray
interactive : True # see http://matplotlib.sourceforge.net/interactive.html
verbose.level : debug-annoying # one of silent, helpful, debug, debug-annoying

Below is the output of the script I submitted when debug-annoying is turned on:
In [3]: x = numpy.arange(1,100,1)

In [4]: e1=-1.8

In [5]: e2=-2.1

In [6]: y = x**2

In [7]: z = x**-2

In [8]: f = figure(num=1)

In [9]: f.clear()

In [10]: ax = f.add_subplot(111)

In [11]: p = ax.plot(x,y)

In [12]: p1 = ax.plot(x,z)

In [13]: title('This works -2.1 but this doesnot $-2.1$')
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
Out[13]: <matplotlib.text.Text instance at 0x8be1e8c>

In [14]: legend((p[0],p1[0]),(r'$x^{%.2g}$'%(e1),r'$x^{%.2g}$'%(e2)))
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
Out[14]: <matplotlib.legend.Legend instance at 0x906f5ac>

In [15]: draw()
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 12.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
    findfont found Bitstream Vera Sans, normal, normal 400, normal, 14.0
findfont returning /usr/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf

It looks like it is finding the fonts in 2.4 when I am using 2.5. I am not sure how to change this behavior nor why that would be the only side effect.

Regards,
Brian

On Dec 5, 2007, at 1:36 PM, Michael Droettboom wrote:

It works for me on Linux with matplotlib 0.91.1, and Cairo 1.4.0.

What version of matplotlib and Cairo are you using? It sounds like it may be pulling in the wrong fonts. Can you please send the contents of your matplotlibrc file, and also set "verbose.level" to "debug-annoying" and send the output?

Cheers,
Mike

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

Hello,

Below is the requested output which looks correct to me:
brian@...1805...:~/dev/pyanalysis$ python
Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__file__
'/usr/lib/python2.5/site-packages/matplotlib/__init__.pyc'
>>> matplotlib.__version__
'0.91.2svn'
>>> matplotlib._get_data_path()
'/usr/lib/python2.5/site-packages/matplotlib/mpl-data'

Deleting the ~/.matplotlib/fontManager.cache did not change the behavior. Thanks for all the help. I really like using matplotlib on my Mac but it doesn't have the power that my Ubuntu box has.

Regards,
Brian

···

On Dec 5, 2007, at 2:52 PM, Michael Droettboom wrote:

What's happening is that it isn't finding the Bakoma Computer Modern fonts. These have a non-standard encoding, so the '-' for instance, is actually under a different character code.

So... we need to track down why it's looking in the wrong place.

Can you send the output of:

> python
Python 2.5.1 (r251:54863, Jul 2 2007, 08:53:40)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__file__
'/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/__init__.pyc'
>>> matplotlib.__version__
'0.91.2.svn'
>>> matplotlib._get_data_path()
'/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/mpl-data'
>>>

You may also try deleting your font cache in ~/.matplotlib/fontManager.cache

Cheers,
Mike

Sorry for the wild goose chase. Now that my memory has been jogged -- This is actually a known problem with the Cairo backend. Cairo only allows access to fonts installed in the normal OS-specific places (and /usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf is definitely not one of them... :wink: Worse than that, AFAIK, there is know way of knowing whether a particular font was found, so we can't give users a nice warning message when your situation occurs.

To remedy: Install all of the matplotlib fonts into a standard place where fontconfig will find them (such as ~/.fonts). Then run fc-cache to regenerate the font cache. Matplotlib's Cairo backend should hopefully work after that.

You can also use the regular PDF backend, which doesn't exhibit this problem. If there's a reason why the Cairo PDF output is better than the normal PDF backend's output for you, please let us know.

What I'm puzzled by now is -- why did the Cairo backend work for you on the Mac? Did you install the fonts there? I'm not on the Mac much --- but I'd be very surprised if Cairo found the CM fonts as installed by matplotlib automagically there.

Cheers,
Mike

Brian Baughman wrote:

···

Hello,

Below is the requested output which looks correct to me:
brian@...1805...:~/dev/pyanalysis$ python
Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__file__
'/usr/lib/python2.5/site-packages/matplotlib/__init__.pyc'
>>> matplotlib.__version__
'0.91.2svn'
>>> matplotlib._get_data_path()
'/usr/lib/python2.5/site-packages/matplotlib/mpl-data'

Deleting the ~/.matplotlib/fontManager.cache did not change the behavior. Thanks for all the help. I really like using matplotlib on my Mac but it doesn't have the power that my Ubuntu box has.

Regards,
Brian

On Dec 5, 2007, at 2:52 PM, Michael Droettboom wrote:

What's happening is that it isn't finding the Bakoma Computer Modern fonts. These have a non-standard encoding, so the '-' for instance, is actually under a different character code.

So... we need to track down why it's looking in the wrong place.

Can you send the output of:

> python
Python 2.5.1 (r251:54863, Jul 2 2007, 08:53:40)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__file__
'/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/__init__.pyc'
>>> matplotlib.__version__
'0.91.2.svn'
>>> matplotlib._get_data_path()
'/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/mpl-data'
>>>

You may also try deleting your font cache in ~/.matplotlib/fontManager.cache

Cheers,
Mike

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

Hello,

On the Mac I use TkAgg and can output PDF files no problem. The only reason I was using GTKCairo was to get the PDF output which was not working with GTKAgg. I just updated to the most recent SVN from the one I was using from earlier today and now I can save to PDF in GTKAgg without troubles. Basically I just wanted something that was interactive till I made the plot to my liking then I could save the figure to a PDF. On the mac this worked with TkAgg without any troubles and now on Linux it works iwth GTKAgg without any troubles. Not sure what changed but thanks for the help.

Regards,
Brian

···

On Dec 5, 2007, at 4:01 PM, Michael Droettboom wrote:

Sorry for the wild goose chase. Now that my memory has been jogged -- This is actually a known problem with the Cairo backend. Cairo only allows access to fonts installed in the normal OS-specific places (and /usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf is definitely not one of them... :wink: Worse than that, AFAIK, there is know way of knowing whether a particular font was found, so we can't give users a nice warning message when your situation occurs.

To remedy: Install all of the matplotlib fonts into a standard place where fontconfig will find them (such as ~/.fonts). Then run fc-cache to regenerate the font cache. Matplotlib's Cairo backend should hopefully work after that.

You can also use the regular PDF backend, which doesn't exhibit this problem. If there's a reason why the Cairo PDF output is better than the normal PDF backend's output for you, please let us know.

What I'm puzzled by now is -- why did the Cairo backend work for you on the Mac? Did you install the fonts there? I'm not on the Mac much --- but I'd be very surprised if Cairo found the CM fonts as installed by matplotlib automagically there.

Cheers,
Mike

Brian Baughman wrote:

Hello,
Below is the requested output which looks correct to me:
brian@...1805...:~/dev/pyanalysis$ python
Python 2.5.1 (r251:54863, Oct 5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__file__
'/usr/lib/python2.5/site-packages/matplotlib/__init__.pyc'
>>> matplotlib.__version__
'0.91.2svn'
>>> matplotlib._get_data_path()
'/usr/lib/python2.5/site-packages/matplotlib/mpl-data'
Deleting the ~/.matplotlib/fontManager.cache did not change the behavior. Thanks for all the help. I really like using matplotlib on my Mac but it doesn't have the power that my Ubuntu box has.
Regards,
Brian
On Dec 5, 2007, at 2:52 PM, Michael Droettboom wrote:

What's happening is that it isn't finding the Bakoma Computer Modern fonts. These have a non-standard encoding, so the '-' for instance, is actually under a different character code.

So... we need to track down why it's looking in the wrong place.

Can you send the output of:

> python
Python 2.5.1 (r251:54863, Jul 2 2007, 08:53:40)
[GCC 3.4.6 20060404 (Red Hat 3.4.6-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__file__
'/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/__init__.pyc'
>>> matplotlib.__version__
'0.91.2.svn'
>>> matplotlib._get_data_path()
'/home/mdroe/usr/lib/python2.5/site-packages/matplotlib/mpl-data'
>>>

You may also try deleting your font cache in ~/.matplotlib/fontManager.cache

Cheers,
Mike

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