Vertical alignment of a text

Indeed I would also use mpl to have png of formulas so as to put them in a
HTML page.

C.

va="baseline" does not work?

-JJ

Dimension of a text in mpl is renderer-dependent in general.
Each renderer has "get_text_width_height_descent" method which

returns

width, height, and descent of the given text.
If you're only interested in latex-rendered text, you may use the
get_text_width_height_descent() method in the TexManager.

As you see, it is possible to know the dimension of the text, but
these functionalities are not exposed to the user, and a bit difficult
to use unless you're familiar with mpl. If you let us know for what
you need to use the depth of the text, we may come up with some

simple

···

On Thu, Jan 15, 2009 at 3:05 AM, <projetmbc@...748...> wrote:

solution.

Regards,

-JJ

I presume that you're only interested in the math formula, and not in
any other graphical functionality of MPL. You may use mathtext module
directly in that case.

from matplotlib.mathtext import MathTextParser

p = MathTextParser("bitmap")
filename, texstr = "test.png", r"$\alpha$"
p.to_png(filename, texstr)
d = p.get_depth(texstr)

Take a look at the documentation for more details.

-JJ

···

On Thu, Jan 15, 2009 at 3:54 PM, <projetmbc@...748...> wrote:

Indeed I would also use mpl to have png of formulas so as to put them in a
HTML page.

C.

va="baseline" does not work?

-JJ

On Thu, Jan 15, 2009 at 3:05 AM, <projetmbc@...748...> wrote:

Dimension of a text in mpl is renderer-dependent in general.
Each renderer has "get_text_width_height_descent" method which

returns

width, height, and descent of the given text.
If you're only interested in latex-rendered text, you may use the
get_text_width_height_descent() method in the TexManager.

As you see, it is possible to know the dimension of the text, but
these functionalities are not exposed to the user, and a bit difficult
to use unless you're familiar with mpl. If you let us know for what
you need to use the depth of the text, we may come up with some

simple

solution.

Regards,

-JJ