Skip to main content

Convert plotly figures to LaTeX / tikz figures

Project description

alt text

Tikzplotly

Convert plotly figures to tikz code for inclusion into PGFPlots (PGF/TikZ) figures.

This results in a tikz code, that can be easily included into your LaTeX document. This also allow to easily edit the content of the figure.

Example

The following Python code

import plotly.express as px
import tikzplotly

df = px.data.gapminder().query("country=='Canada'")
fig = px.line(df, x="year", y="lifeExp", title='Life expectancy in Canada')
tikzplotly.save("example.tex", fig)

will result in the following tikz code

% This file was created with tikzplotly version 0.0.1.
\begin{tikzpicture}

\definecolor{636efa}{HTML}{636efa}

\begin{axis}[
title=Life expectancy in Canada,
xlabel=year,
ylabel=lifeExp,
]
\addplot+ [mark=none, solid, color=636efa, forget plot] table {%
1952 68.75
1957 69.96
1962 71.3
1967 72.13
1972 72.88
1977 74.21
1982 75.76
1987 76.86
1992 77.95
1997 78.61
2002 79.77
2007 80.653
};
\end{axis}
\end{tikzpicture}

Note

  • This module is in development and new features are added bit by bit, when needed. If you have a feature request, please open an issue with the plotly figure you want to convert and the desired output. You can also submit a pull request with the desired feature !
  • Some feature can result in different output between the plotly figure and the tikz figure, for instance the size of markers.

References

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tikzplotly-0.1.0.tar.gz (24.1 kB view hashes)

Uploaded Source

Built Distribution

tikzplotly-0.1.0-py3-none-any.whl (20.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page