From: John H. <jdh...@ac...> - 2004-11-29 20:51:14
|
>>>>> "Carol" == Carol Leger <car...@sr...> writes: Carol> I want to make a semi-transparent box around the text Carol> labels along the radial axis of a polar plot. Is there a Carol> method that returns the coordinates of a box that encloses Carol> the text? Carol> I see that a text instance has a method called Carol> get_window_extent. What does it return? What would I use Carol> for the parameter 'renderer'? Are there any examples Carol> showing how to use this? The problem here is that there is no way to know the text size (bounding box) until the renderer (backend) is known. matplotlib enforces a rigid separation between the "artists" (lines, texts, things that go into a figure) and the things that draw them (renderer / backend) . In most cases this presents no difficulties, but in the case of text it does, since layout information is not available until the figure is drawn, since that is when the backend/renderer is drawn. So that is what the renderer is and the short answer is that it is not available at the matlab interface level. But I've been wanting to support the ability to put bounding boxes around text instances and your post triggered the idea on how to do this. I added a new text property "bbox" which takes as a dictionary of Rectangle properties t = title('hi mom', bbox={'edgecolor':'k', 'facecolor':'r', 'alpha':0.5}) In addition to the rectangle properties, the bbox dict accepts an additional property 'pad' which gives the padding around the text in points. I checked the changes into CVS - it usually takes the mirrors a few hours to update. If you get a snazzy screenshot of your polar plot after all these customizations that would look nice on the web site, please send it my way! JDH |