SourceForge logo
SourceForge logo
Menu

matplotlib-users

From: Carol L. <car...@sr...> - 2004年11月29日 19:54:00
I want to make a semi-transparent box around the text labels along the 
radial axis of a polar plot. Is there a method that returns the 
coordinates of a box that encloses the text?
I see that a text instance has a method called get_window_extent. What 
does it return? What would I use for the parameter 'renderer'? Are 
there any examples showing how to use this?
-- 
Ms. Carol A. Leger
SRI International			Phone: (650) 859-4114
333 Ravenswood Avenue G-273
Menlo Park, CA 94025 e-mail: le...@sr...
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
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /