All,
This error:
The debugged program raised the exception unhandled AttributeError
“‘FigureCanvasMac’ object has no attribute ‘buffer_rgba’”
File: /Users/darnold/Documents/temp/Matplotlib/PylabExamples/agg_buffer_to_array.py, Line: 16
is raised by the following script on my Macbook.
agg_buffer_to_array.py
import matplotlib
matplotlib.use(‘macosx’)
from pylab import figure, show
import numpy as np
make an agg figure
fig = figure()
ax = fig.add_subplot(111)
ax.plot([1,2,3])
ax.set_title(‘a simple figure’)
fig.canvas.draw()
grab rhe pixel buffer and dumpy it into a numpy array
buf = fig.canvas.buffer_rgba(0,0)
l, b, w, h = fig.bbox.bounds
X = np.fromstring(buf, np.uint8)
X.shape = h,w,4
now display the array X as an Axes in a new figure
fig2 = figure()
ax2 = fig2.add_subplot(111, frameon=False)
ax2.imshow(X)
show()
This is captured from: http://matplotlib.sourceforge.net/examples/pylab_examples/agg_buffer_to_array.html
With:
matplotlib.use(‘Agg’)
Nothing happens at all. With --verbose-helpful, yields the following:
$HOME=/Users/darnold
CONFIGDIR=/Users/darnold/.matplotlib
matplotlib data path /Library/Frameworks/Python.framework/Versions/6.0.0/lib/python2.6/site-packages/matplotlib/mpl-data
loaded rc file /Users/darnold/.matplotlib/matplotlibrc
matplotlib version 0.99.1.1
verbose.level helpful
interactive is False
units is False
platform is darwin
Using fontManager instance from /Users/darnold/.matplotlib/fontList.cache
backend agg version v2.2
findfont: Matching :family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=medium to Bitstream Vera Sans (/Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg/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 (/Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib-0.98.5.2n2-py2.5-macosx-10.3-fat.egg/matplotlib/mpl-data/fonts/ttf/Vera.ttf) with score of 0.000000
Both
matplotlib.use(‘tkagg’)
and
matplotlib.use(‘wxagg’)
work as they should.
David.