Unicode error using matplotlib with log scale in Windows

I am using python 2.6 and matplotlib. If I run the histogram_demo.py sample provided on the matplotlib gallery page, it works fine. I greatly simplified this script:

import numpy as np
import matplotlib.pyplot as plt

mu, sigma = 100, 15
x = mu + sigma * np.random.randn(10000)

fig = plt.figure()
ax = fig.add_subplot(111)

n, bins, patches = ax.hist(x, 50, normed=1, facecolor='green', alpha=0.75)

ax.set_yscale('log')  # <---- add this line to generate the error
plt.show()

I get this error (in line plt.show()):

TypeError: coercing to Unicode: need string or buffer, dict found

I tried changing the backend to a lot of different values ​​- nothing helps. I use Qt4Agg. Is this a font problem? It seems that this should be something with my configuration. Note. Due to other problems, I just installed a new copy of python26, matplotlib, numpy, scipy. I have another XP-box running python26 and it executes both versions of the script without errors. I hope someone can help. Thank you very much in advance.

+5
5

matplotlib, /usr/lib/pymodules/python 2.6/matplotlib/font_manager.py:1220. ; matplotlib.

if best_font is None or best_score >= 10.0:
    verbose.report('findfont: Could not match %s. Returning %s' %
                       (prop, self.defaultFont))
    [+]result = self.defaultFont[fontext]
    [-]result = self.defaultFont
    print "defaultFont", result
else:
    verbose.report('findfont: Matching %s to %s (%s) with score of %f' %
                       (prop, best_font.name, best_font.fname, best_score))
    result = best_font.fname
    print "best_font", result

, "" , . , , - .

, !

+8

matplotlib 0.98.5.2. , matplotlib 1.0.1 (0.99.3 ), ~/.matplotlib. , Windows.

+5

, github

https://github.com/matplotlib/matplotlib/issues/198

- .matplotlib/fontList.cache .

+1

, , , . / Matplotlib Numpy, - ( Python 2.5).

:

self.ax.cla()
if self.logy: self.ax.set_yscale('log')
self.canvas.draw()

, self.logy True, , . .

, Matplotlib Numpy . , , , . , .

, / .

:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\path\to\file\being\called\by\Tkinter.py", line 1081, in refresh
    self.canvas.draw()
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_tkagg.py", line 215, in draw
    FigureCanvasAgg.draw(self)
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py", line 314, in draw
    self.figure.draw(self.renderer)
  File "C:\Python25\Lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
    draw(artist, renderer, *kl)
  File "C:\Python25\Lib\site-packages\matplotlib\figure.py", line 773, in draw
    for a in self.axes: a.draw(renderer)
  File "C:\Python25\Lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
    draw(artist, renderer, *kl)
  File "C:\Python25\Lib\site-packages\matplotlib\axes.py", line 1735, in draw
    a.draw(renderer)
  File "C:\Python25\Lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
    draw(artist, renderer, *kl)
  File "C:\Python25\Lib\site-packages\matplotlib\axis.py", line 742, in draw
    tick.draw(renderer)
  File "C:\Python25\Lib\site-packages\matplotlib\artist.py", line 46, in draw_wrapper
    draw(artist, renderer, *kl)
  File "C:\Python25\Lib\site-packages\matplotlib\axis.py", line 196, in draw
    self.label1.draw(renderer)
  File "C:\Python25\Lib\site-packages\matplotlib\text.py", line 515, in draw
    bbox, info = self._get_layout(renderer)
  File "C:\Python25\Lib\site-packages\matplotlib\text.py", line 279, in _get_layout
    clean_line, self._fontproperties, ismath=ismath)
  File "C:\Python25\Lib\site-packages\matplotlib\backends\backend_agg.py", line 156, in get_text_width_height_descent
    self.mathtext_parser.parse(s, self.dpi, prop)
  File "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", line 2797, in parse
    font_output = fontset_class(prop, backend)
  File "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", line 658, in __init__
    self._stix_fallback = StixFonts(*args, **kwargs)
  File "C:\Python25\Lib\site-packages\matplotlib\mathtext.py", line 900, in __init__
    fullpath = findfont(name)
  File "C:\Python25\Lib\site-packages\matplotlib\font_manager.py", line 1306, in findfont
    if not os.path.exists(font):
  File "C:\Python25\lib\ntpath.py", line 255, in exists
    st = os.stat(path)
TypeError: coercing to Unicode: need string or buffer, dict found
0

!

Macplotlib Mac OS 10.6 ( Python2.5 - ), matplotlib ( !)

, , , , , ~/.matplotlib/matplotlibrc LaTex, text.usetex : True ( , , "" ).

"", script, /.

0

All Articles