From: Al S. <a.d...@wo...> - 2004-03-08 16:25:54
|
[ I posted this directly to mat...@li... previously, but I didn't see it show up there. Sorry if you got this before. --Al] I am generating a plot with multi-line ticklabels. Although the plot displays normally, clicking on the SAVE icon fails (after selecting a target file name ending with .ps). I tracked this down as far as afm.get_str_bbox(), line 307 in afm.py It appears to me that the '\n' character in my multi-line label is causing the following error: File "/usr/local/lib/python2.3/site-packages/matplotlib/afm.py", line 307, in get_str_bbox wx, name, bbox = self._metrics[ord(c)] KeyError: 10 Note that '\n' == 10. I confirmed the failure with a tiny example: Run the following and click on the SAVE icon, enter a file name ending in .ps, and observe the failure. ################################ from matplotlib.matlab import * plot([1,2,3,4], [1,4,9,16]) set(gca(), 'xticks', [1,2,3,4]) t = set(gca(), 'xticklabels', ['Frogs\nOKAY 1', 'Hogs\nFine 2', 'Bogs\nGOOD 3', 'Slogs']) show() ################################ Although I realize that computing the bounding box of a multi-line text is a bit more complex, I would really like to see this supported. Also, I don't know in how many other places the embedded '\n' will cause problems. Thanks. -- Al Schapira <a.d...@wo...> |