Ask Your Question
1

How to fill rectangle around the text (or measure string)?

asked 2015-03-20 17:53:15 -0600

Eugene gravatar image

Hello!

I would like to fill a rectangle around the text on the plot, to make text more readable (same way it is done for the legend), the perfect way would be:

text('Sage!', (0, 0), fill=True, fill_color='blue', edgecolor='black')

But unfortunately there are no such options. I tried to write a custom function using text and polygon2d, but the problem appeared in calculating the size of the rectangle around the arbitrary text.

So, could anyone help me figure out how to calculate the size of the rectangle around the text (something like string measuring with consideration of font settings?), or may be suggest a better approach?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-03-21 15:47:00 -0600

Hello,

It seems that we do not currently supports all options of matplotlib. I opened the trac ticket #18035 for that issue. Hopefully, if somebody does a review of the ticket these options will be available in a next release of Sage.

In the mean time you can use matplotlib directly or have a look at this related question.

Vincent

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-03-20 17:53:15 -0600

Seen: 101 times

Last updated: Mar 21 '15