[ Web Proxy ]
URL:
Viewing: https://plotly.com/python/LaTeX/ [Back]  [Original]

Latex in Python
Quick Reference On This Page
See what's possible with Plotly Dash for your data analytics. Explore interactive dashboard examples and AI apps built for use cases across finance, energy, and more. [See what's possible with Plotly Dash for your data analytics. Explore interactive dashboard examples and AI apps built for use cases across finance, energy, and more.]

LaTeX in Python

How to add LaTeX to python graphs.


Plotly Studio: Transform any dataset into an interactive data application in minutes with AI. Try Plotly Studio now.

LaTeX Typesetting

Figure titles, axis labels and annotations all accept LaTeX directives for rendering mathematical formulas and notation, when the entire label is surrounded by dollar signs $...$. This rendering is handled by the MathJax library, which must be loaded in the environment where figures are being rendered. MathJax is included by default in Jupyter-like environments. When embedding Plotly figures in other contexts it may be required to ensure that MathJax is separately loaded, for example via a <script> tag pointing to a content-delivery network (CDN). Plotly.py v7 and above supports MathJax versions 3 and 4. Earlier Plotly.py versions support MathJax versions 2 and 3.

In [1]:
import plotly.express as px

fig = px.line(x=[1, 2, 3, 4], y=[1, 4, 9, 16], title=r'$\alpha_{1c} = 352 \pm 11 \text{ km s}^{-1}$')
fig.update_layout(
    xaxis_title=r'$\sqrt{(n_\text{c}(t|{T_\text{early}}))}$',
    yaxis_title=r'$d, r \text{ (solar radius)}$'
)
fig.show()
In [2]:
import plotly.graph_objs as go

fig = go.Figure()
fig.add_trace(go.Scatter(
    x=[1, 2, 3, 4],
    y=[1, 4, 9, 16],
    name=r'$\alpha_{1c} = 352 \pm 11 \text{ km s}^{-1}$'
))
fig.add_trace(go.Scatter(
    x=[1, 2, 3, 4],
    y=[0.5, 2, 4.5, 8],
    name=r'$\beta_{1c} = 25 \pm 11 \text{ km s}^{-1}$'
))
fig.update_layout(
    xaxis_title=r'$\sqrt{(n_\text{c}(t|{T_\text{early}}))}$',
    yaxis_title=r'$d, r \text{ (solar radius)}$'
)
fig.show()

What About Dash?

Dash is an open-source framework for building analytical applications, with no Javascript required, and it is tightly integrated with the Plotly graphing library.

Learn about how to install Dash at https://dash.plot.ly/installation.

Everywhere in this page that you see fig.show(), you can display the same figure in a Dash application by passing it to the figure argument of the Graph component from the built-in dash_core_components package like this:

import plotly.graph_objects as go # or plotly.express as px
fig = go.Figure() # or any Plotly Express function e.g. px.bar(...)
# fig.add_trace( ... )
# fig.update_layout( ... )

from dash import Dash, dcc, html

app = Dash()
app.layout = html.Div([
    dcc.Graph(figure=fig)
])

app.run(debug=True, use_reloader=False)  # Turn off reloader if inside Jupyter
plotly-studio.png [plotly-studio.png]
Copyright © 2026 Plotly. All rights reserved.
Terms of Service Privacy Policy

Web Proxy Viewer  |  New URL  |  Original Page