Export with LaTeX
Make SVG visualization
If you want math equations in LaTeX, or you just want to export your visualization to LaTeX, you should follow this tutorial.
Let's start with this simple code:
import plotynium as ply
x = list(range(0, 21))
data = [
{
"x": xi,
"y": pow(xi, i + 1),
"label": (f"$y = x^{i + 1}$" if i > 0 else "$y = x$"),
}
for i in range(3)
for xi in x
]
plot = ply.plot(
marks=[ply.line(data, x="x", y="y", stroke="label")],
color={"legend": True, "scheme": ply.Scheme.OBSERVABLE_10},
y={"specifier": "~s"},
)
with open("figure.svg", "w") as file:
file.write(str(plot))
Expected output
As you can see, labels contain $ in order to make math equations through LaTeX.
Convert and build your PDF
-
Convert the
figure.svgtofigure.pdf_texwithinkscape. -
Change the font size with the following command:
-
Create a file
file.texand add the following content: -
Compile the LaTeX file with
pdflatex: -
Open
file.pdf