matplotlib and QT 4.5.2

Hi, all

I try to use last stable version of matplotlib 0.9.85.2 with PyQt 4.5.2 under Windows XP Pro SP3, Python 2.5.2 and get error

Traceback (most recent call last):
File "/home/alex/.qgis//python/plugins/statist/statist.py", line 114, in
doCalcStats
   d = doStatist.dlgStatist( self.iface )
File "/home/alex/.qgis//python/plugins/statist/doStatist.py", line 81, in
__init__
   self.canvas = FigureCanvas( self.figure )
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_qt4agg.py",
line 57, in __init__
   FigureCanvasQT.__init__( self, figure )
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_qt4.py",
line 100, in __init__
   self.resize( w, h )
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_qt4.py",
line 162, in resize
   self.draw()
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_qt4agg.py",
line 133, in draw
   FigureCanvasAgg.draw(self)
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 261, in draw
   self.figure.draw(self.renderer)
File "/usr/lib/python2.5/site-packages/matplotlib/figure.py", line 762, in
draw
   for t in self.texts: t.draw(renderer)
File "/usr/lib/python2.5/site-packages/matplotlib/text.py", line 299, in draw
   bbox, info = self._get_layout(renderer)
File "/usr/lib/python2.5/site-packages/matplotlib/text.py", line 193, in
_get_layout
   'lp', self._fontproperties, ismath=False)
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 137, in get_text_width_height_descent
   font = self._get_agg_font(prop)
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 177, in _get_agg_font
   font = FT2Font(str(fname))
RuntimeError: Could not load facefile /; Unknown_File_Format

Does this means that matplotlib don't work with QT 4.5.2 and I need latest svn version?
With PyQt 4.4.3 same program work fine and there is no errors

Thanks,
  Alexander Bruy

-- реклама -----------------------------------------------------------
Поторопись зарегистрировать самый короткий почтовый адрес @i.ua
http://mail.i.ua/reg - и получи 1Gb для хранения писем

I don't think this is related to Qt at all, but is illustrating some sort of bug in the font lookup code.

Can you try removing fontList.cache and trying again? I *believe* it lives in "C:\Documents and Settings\${YOURNAME}\Local Settings\.matplotlib" on Windows, but I'm not a regular Windows user. You may have to search for it.

Also, set the rcParam['verbose.level'] to 'debug-annoying' and send the output. That may provide some clues as to how the font lookup is failing.

Cheers,
Mike

Alexander Bruy wrote:

···

Hi, all

I try to use last stable version of matplotlib 0.9.85.2 with PyQt 4.5.2 under Windows XP Pro SP3, Python 2.5.2 and get error

Traceback (most recent call last):
File "/home/alex/.qgis//python/plugins/statist/statist.py", line 114, in
doCalcStats
   d = doStatist.dlgStatist( self.iface )
File "/home/alex/.qgis//python/plugins/statist/doStatist.py", line 81, in
__init__
   self.canvas = FigureCanvas( self.figure )
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_qt4agg.py",
line 57, in __init__
   FigureCanvasQT.__init__( self, figure )
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_qt4.py",
line 100, in __init__
   self.resize( w, h )
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_qt4.py",
line 162, in resize
   self.draw()
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_qt4agg.py",
line 133, in draw
   FigureCanvasAgg.draw(self)
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 261, in draw
   self.figure.draw(self.renderer)
File "/usr/lib/python2.5/site-packages/matplotlib/figure.py", line 762, in
draw
   for t in self.texts: t.draw(renderer)
File "/usr/lib/python2.5/site-packages/matplotlib/text.py", line 299, in draw
   bbox, info = self._get_layout(renderer)
File "/usr/lib/python2.5/site-packages/matplotlib/text.py", line 193, in
_get_layout
   'lp', self._fontproperties, ismath=False)
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 137, in get_text_width_height_descent
   font = self._get_agg_font(prop)
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_agg.py",
line 177, in _get_agg_font
   font = FT2Font(str(fname))
RuntimeError: Could not load facefile /; Unknown_File_Format

Does this means that matplotlib don't work with QT 4.5.2 and I need latest svn version?
With PyQt 4.4.3 same program work fine and there is no errors

Thanks,
  Alexander Bruy

-- ������� -----------------------------------------------------------
���������� ���������������� ����� �������� �������� ����� @i.ua
http://mail.i.ua/reg - � ������ 1Gb ��� �������� �����

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
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

2009/8/5 Michael Droettboom <mdroe@...86...>:

I don't think this is related to Qt at all, but is illustrating some
sort of bug in the font lookup code.

Can you try removing fontList.cache and trying again? I *believe* it
lives in "C:\Documents and Settings\${YOURNAME}\Local
Settings\.matplotlib" on Windows, but I'm not a regular Windows user.
You may have to search for it.

Running any pylab script with --verbose-helpful should report the font
cache location; see the line starting with "Using fontManager instance
from "....

johnh@...2715...:pylab_examples> python simple_plot.py --verbose-helpful

$HOME=/home/titan/johnh
CONFIGDIR=/home/titan/johnh/.matplotlib
matplotlib data path
/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/mpl-data
loaded rc file /home/titan/johnh/.matplotlib/matplotlibrc
matplotlib version 0.99.0.rc1
verbose.level helpful
interactive is False
units is False
platform is sunos5
Using fontManager instance from /home/titan/johnh/.matplotlib/fontList.cache
backend TkAgg version 8.4
findfont: Matching
:family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium
to Bitstream Vera Sans
(/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf)
with score of 0.000000
findfont: Matching
:family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=large
to Bitstream Vera Sans
(/home/titan/johnh/dev/lib/python2.4/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf)
with score of 0.000000

Thanks for explanation Michael.

   I do more intensive testing and found than this problem have place
in Windows and Linux in all verions of Qt which I have (4.4.3 and 4.5.2).
So you are right saying

I don't think this is related to Qt at all, but is illustrating some
sort of bug in the font lookup code.

I try to perform some testing with your instructions

Can you try removing fontList.cache and trying again? I *believe* it
lives in "C:\Documents and Settings\${YOURNAME}\Local
Settings\.matplotlib" on Windows, but I'm not a regular Windows user.
You may have to search for it.

I remove fontList.cache and try again. And have this debug output:

Traceback (most recent call last):
  File "C:\OSGeo4W\apps\qgis-dev\python\plugins\statist\statist.py", line 114, in doCalcStats
    d = doStatist.dlgStatist( self.iface )
  File "C:\OSGeo4W\apps\qgis-dev\python\plugins\statist\doStatist.py", line 81, in __init__
    self.canvas = FigureCanvas( self.figure )
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 57, in __init__
    FigureCanvasQT.__init__( self, figure )
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4.py", line 103, in __init__
    self.resize( w, h )
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4.py", line 171, in resize
    self.draw()
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 133, in draw
    FigureCanvasAgg.draw(self)
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py", line 279, in draw
    self.figure.draw(self.renderer)
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\figure.py", line 775, in draw
    for t in self.texts: t.draw(renderer)
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\text.py", line 452, in draw
    bbox, info = self._get_layout(renderer)
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\text.py", line 246, in _get_layout
    'lp', self._fontproperties, ismath=False)
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py", line 155, in get_text_width_height_descent
    font = self._get_agg_font(prop)
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py", line 195, in _get_agg_font
    font = FT2Font(str(fname))
RuntimeError: Could not open facefile C:/OSGeo4W/apps/qgis-dev/python/plugins/statist/font/CharisSILR.ttf; Cannot_Open_Resource

And then

Also, set the rcParam['verbose.level'] to 'debug-annoying' and send the
output. That may provide some clues as to how the font lookup is failing.

I set rcParam['verbose.level'] to 'debug-annoying' and receive large output (see attachment)

I do this under Windows, but my colleagues have same problem under Linux, so I ask them to
do same things and can send theirs logs later

-- реклама -----------------------------------------------------------
Поторопись зарегистрировать самый короткий почтовый адрес @i.ua
http://mail.i.ua/reg - и получи 1Gb для хранения писем

mpl.zip (3.85 KB)

Also, set the rcParam['verbose.level'] to 'debug-annoying' and send the
output. That may provide some clues as to how the font lookup is failing.

Here log file obtained on Linux box

Regards,
Alexander Bruy

-- реклама -----------------------------------------------------------
Поторопись зарегистрировать самый короткий почтовый адрес @i.ua
http://mail.i.ua/reg - и получи 1Gb для хранения писем

matplotliblog.tar.gz (3.43 KB)

It looks as if the statist package is passing a hard-coded font file path to matplotlib:

  C:/OSGeo4W/apps/qgis-dev/python/plugins/statist/font/CharisSILR.ttf

because of the following line in the log:

findfont returning C:/OSGeo4W/apps/qgis-dev/python/plugins/statist/font/CharisSILR.ttf

Does this file exist on your system? In any case, it looks from here (without being able to play with all the moving parts) that the bug is in statist.py, and matplotlib is just blindly following the request to use a particular font.

Cheers,
Mike

Alexander Bruy wrote:

···

Thanks for explanation Michael.

   I do more intensive testing and found than this problem have place
in Windows and Linux in all verions of Qt which I have (4.4.3 and 4.5.2).
So you are right saying
  

I don't think this is related to Qt at all, but is illustrating some sort of bug in the font lookup code.
    
I try to perform some testing with your instructions
  
Can you try removing fontList.cache and trying again? I *believe* it lives in "C:\Documents and Settings\${YOURNAME}\Local Settings\.matplotlib" on Windows, but I'm not a regular Windows user. You may have to search for it.
    

I remove fontList.cache and try again. And have this debug output:

Traceback (most recent call last):
  File "C:\OSGeo4W\apps\qgis-dev\python\plugins\statist\statist.py", line 114, in doCalcStats
    d = doStatist.dlgStatist( self.iface )
  File "C:\OSGeo4W\apps\qgis-dev\python\plugins\statist\doStatist.py", line 81, in __init__
    self.canvas = FigureCanvas( self.figure )
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 57, in __init__
    FigureCanvasQT.__init__( self, figure )
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4.py", line 103, in __init__
    self.resize( w, h )
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4.py", line 171, in resize
    self.draw()
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 133, in draw
    FigureCanvasAgg.draw(self)
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py", line 279, in draw
    self.figure.draw(self.renderer)
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\figure.py", line 775, in draw
    for t in self.texts: t.draw(renderer)
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\text.py", line 452, in draw
    bbox, info = self._get_layout(renderer)
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\text.py", line 246, in _get_layout
    'lp', self._fontproperties, ismath=False)
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py", line 155, in get_text_width_height_descent
    font = self._get_agg_font(prop)
  File "C:\OSGeo4W\apps\Python25\lib\site-packages\matplotlib\backends\backend_agg.py", line 195, in _get_agg_font
    font = FT2Font(str(fname))
RuntimeError: Could not open facefile C:/OSGeo4W/apps/qgis-dev/python/plugins/statist/font/CharisSILR.ttf; Cannot_Open_Resource

And then
  

Also, set the rcParam['verbose.level'] to 'debug-annoying' and send the output. That may provide some clues as to how the font lookup is failing.
    
I set rcParam['verbose.level'] to 'debug-annoying' and receive large output (see attachment)

I do this under Windows, but my colleagues have same problem under Linux, so I ask them to
do same things and can send theirs logs later

-- ������� -----------------------------------------------------------
���������� ���������������� ����� �������� �������� ����� @i.ua
http://mail.i.ua/reg - � ������ 1Gb ��� �������� �����

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

This log file appears to be truncated.

Cheers,
Mike

Alexander Bruy wrote:

···

Also, set the rcParam['verbose.level'] to 'debug-annoying' and send the output. That may provide some clues as to how the font lookup is failing.
    
Here log file obtained on Linux box

Regards,
Alexander Bruy

-- ������� -----------------------------------------------------------
���������� ���������������� ����� �������� �������� ����� @i.ua
http://mail.i.ua/reg - � ������ 1Gb ��� �������� �����

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