On Wednesday, December 14, 2011, Keld Lundgaard <keld.lundga...@gmail.com>
wrote:
>
> Hi
>
> How do I get the information about the endpoint of a text element?
>
> Example:
>
> import matplotlib.pylab as plt
> text = plt.text(0.5,0.5,'hi')
> plt.show()
>
> In the dataTrans coordinates, where does the text string ends?
>
>
> I have spent some time now trying to solve this, seemingly simple problem,
> so I appreciate any help a lot!
>
>
> Thanks in advance!
>
> / Keld

It is actually a very difficult thing to do, and is why mpl does not
provide a mechanism to find out until after rendering.  The problem is that
-- in the general case -- it is not possible to know ahead of time how much
space some text will take up for an arbitrary font, style and size.

You can have the figure get rendered, and then you can query the text's
bounding box, if I understand correctly.  Maybe the code for tight_layout()
might show how it does this.

Ben Root
------------------------------------------------------------------------------
10 Tips for Better Server Consolidation
Server virtualization is being driven by many needs.  
But none more important than the need to reduce IT complexity 
while improving strategic productivity.  Learn More! 
http://www.accelacomm.com/jaw/sdnl/114/51507609/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to