On Thu, 17 Nov 2022 at 14:01, Anton Makarov <antonvmaka...@gmail.com> wrote:
>
> I need to convert sympy tree expression to svg, for instance:
> a = sympify("1+2/3")
> b = sympify("x+5/x+3*sin(x)")
> c = a + b
> and i need to convert c expression to svg string

Your question is very ambiguous. Since SVG is an image format then
this implies that you want an image of the expression somehow but
there are many different ways that an expression could be represented
as an image. Do you want an image of the tree or a typeset equation
(like from LaTeX) or something else?

> I don't want an svg file, i want the string. Something like this:
> svg_string = <svg width="134" height="32" viewBox="-1 -1 134 32">
> ...

That's just the contents of an SVG file. If you had an SVG file then
you could just read the file to get the string.

An SVG file represents an image but you haven't said what you want an
image of. Also you don't say *why* you want an SVG image. The usual
reason for wanting SVG is to have an image in a webpage but the
easiest and potentially best way to have a typeset equation in a
webpage (assuming that is what you want) is to use Mathjax in which
case you should just convert your expression to LaTeX:

In [3]: latex(x**2)
Out[3]: 'x^{2}'

--
Oscar

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxTUVj78Z0H%2BzAJWkwbN_3fvi3A_JBUCpOkEe1qCB%2BuJww%40mail.gmail.com.

Reply via email to