Skip to main content

logo-tikzplotly

PyPi Version PyPi Downloads PyPi License PyPI pyversions

GitHub release Issue codecov GitHub Actions Workflow Status

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 allows to easily edit the content of the figure.

More details can be found in the documentation.

Example

The following Python code

import plotly.express as px
import tikzplotly

df = px.data.gapminder().query("continent == 'Oceania'")
fig = px.line(df, x='year', y='lifeExp', color='country', markers=True)
tikzplotly.save("example.tex", fig)

will result in the following tikz code

\pgfplotstableread{
x Australia NewZealand
1952 69.12 69.39
1957 70.33 70.26
1962 70.93 71.24
1967 71.1 71.52
1972 71.93 71.89
1977 73.49 72.22
1982 74.74 73.84
1987 76.32 74.32
1992 77.56 76.33
1997 78.83 77.55
2002 80.37 79.11
2007 81.235 80.204
}\dataA

\begin{tikzpicture}

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

\begin{axis}[
xlabel=year,
ylabel=lifeExp
]
\addplot+ [mark=*, solid, color=636efa] table[y=Australia] {\dataA};
\addlegendentry{Australia}
\addplot+ [mark=*, solid, color=EF553B] table[y=NewZealand] {\dataA};
\addlegendentry{New Zealand}
\end{axis}
\end{tikzpicture}

Installation

Tikzplotly is available from the Python Package Index, so it can be installed with pip :

pip install tikzplotly

Usage

  1. Generate the figure with Plotly,
  2. Invoke tikzplotly to convert the figure to tikz code :
import tikzplotly

tikzplotly.save("figure.tex", fig)
  1. Add the content of the generated file figure.tex to your LaTeX document :
\input{figure.tex}

To correctly compile the document, you will need to add the following packages to your preamble :

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

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, more details can be found in the documentation.

References

License

This project is licensed under the MIT License.

Metadata

Release files for tikzplotly 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tikzplotly 0.2.3
File Size Uploaded Provenance Actions
tikzplotly-0.2.3.tar.gz 69.3 kB Without provenance Details for tikzplotly-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tikzplotly 0.2.3
File Interpreter ABI Platform Actions
tikzplotly-0.2.3-py3-none-any.whl Python 3 none any Details for tikzplotly-0.2.3-py3-none-any.whl

Total release size: 137.0 kB

Release files / tikzplotly-0.2.3.tar.gz

Download URL tikzplotly-0.2.3.tar.gz
Size 69.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bbfab60bba36ecaef3324b9db28e98afb903e0815b6ea829b65773c542d25bb3
BLAKE2b-256 checksum
How to use checksums
9c3460971ea71051902cda47ac9363ed11dc1580b12347f57c8d37041024c25f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / tikzplotly-0.2.3-py3-none-any.whl

Download URL tikzplotly-0.2.3-py3-none-any.whl
Size 67.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d70f84a696a536ee3e73d726a39b14ab8d724b7100076222cd7fa822de727130
BLAKE2b-256 checksum
How to use checksums
8d1915e1747e11becad70d7ec730fe3832f337ca984d42b369f5e7c3426ff81e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for tikzplotly 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page