Hi everyone
I've found a few problems in the current matplotlib-py3 branch in the
_macosx.c code. I've put the fixes in a fork here:
https://github.com/grahame/matplotlib-py3
I saw a pull request for a similar patch with a lot of comments that
seems to be stuck, so I thought I'd ask here what to do. It'd be great
to get the master branch working on Mac.
Another thing - I think I've found a str/bytes bug which I can't
figure it out. I've attached the code, if I run it on my machine I get
this output:
Traceback (most recent call last):
File "crash.py", line 24, in <module>
fig.canvas.print_figure(open('test.png', 'wb'), bbox_inches='tight')
File "/opt/shrubbery/lib/python3.2/site-packages/matplotlib/backend_bases.py",
line 1951, in print_figure
bbox_inches = self.figure.get_tightbbox(renderer)
File "/opt/shrubbery/lib/python3.2/site-packages/matplotlib/figure.py",
line 1292, in get_tightbbox
for ax in self.axes:
File "/opt/shrubbery/lib/python3.2/site-packages/matplotlib/figure.py",
line 290, in _get_axes
return self._axstack.as_list()
File "/opt/shrubbery/lib/python3.2/site-packages/matplotlib/figure.py",
line 59, in as_list
ia_list = [a for k, a in self._elements]
File "/opt/shrubbery/lib/python3.2/site-packages/matplotlib/figure.py",
line 59, in <listcomp>
ia_list = [a for k, a in self._elements]
TypeError: string argument expected, got 'bytes'
It's definitely something to do with the bbox_inches='tight' argument,
if I take that out everything works. Using the debugger I can't see
anything in any stack frame that explains the traceback - really odd!
Thanks
Grahame
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_axes([0.1, 0.1, 0.4, 0.7])
ax2 = fig.add_axes([0.55, 0.1, 0.4, 0.7])
x = np.arange(0.0, 2.0, 0.02)
y1 = np.sin(2*np.pi*x)
y2 = np.exp(-x)
l1, l2 = ax1.plot(x, y1, 'rs-', x, y2, 'go')
y3 = np.sin(4*np.pi*x)
y4 = np.exp(-2*x)
l3, l4 = ax2.plot(x, y3, 'yd-', x, y3, 'k^')
fig.legend((l1, l2), ('Line 1', 'Line 2'), 'upper left')
fig.legend((l3, l4), ('Line 3', 'Line 4'), 'upper right')
## plt.show()
fig.canvas.print_figure(open('test.png', 'wb'), bbox_inches='tight')
------------------------------------------------------------------------------
EMC VNX: the world's simplest storage, starting under $10K
The only unified storage solution that offers unified management
Up to 160% more powerful than alternatives and 25% more efficient.
Guaranteed. http://p.sf.net/sfu/emc-vnx-dev2dev
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel