I am trying to draw some text inside of a rectangle. The text can
be longer than the rectangle, so I would like to wrap the text. I doubt
MPL has this kind of functionality built in, so I am expecting to write it
myself.
I think I read somewhere that it is not possible to get the length of
text in MPL. Is this true? This would be the basic mechanism
needed to implement this.
I just want to know if this is possible or not, and any pointers if
anyone has some.
Thanks,
-Ben
Hi,
I guess the extent of the rendered text is not known until the figure
is drawn. The link below would be helpful.
http://matplotlib.sourceforge.net/doc/html/faq/howto_faq.html#how-do-i-automatically-make-room-for-my-tick-labels
So. it is possible to know the text length, but you need to wait until
the drawing time.
I guess the legend class might be helpful, as it adjust its position
at the drawing time according to the text size. But wrapping a text
(in general way) seems not easy to me.
Anyhow, the easiest way I can think of is to rely on LaTeX for wrapping.
text(0.5, 2.5, r"\parbox[b]{2 in}{really really really really really
really long line}", va="top")
It may be a bit tricky to get the right vertical alignment though.
Regards,
-JJ
ยทยทยท
On Thu, Aug 21, 2008 at 12:55 PM, Ben Axelrod <baxelrod@...2066...> wrote:
I am trying to draw some text inside of a rectangle. The text can be longer
than the rectangle, so I would like to wrap the text. I doubt MPL has this
kind of functionality built in, so I am expecting to write it myself.
I think I read somewhere that it is not possible to get the length of text
in MPL. Is this true? This would be the basic mechanism needed to
implement this.
I just want to know if this is possible or not, and any pointers if anyone
has some.
Thanks,
-Ben
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options