Overview

plotly.py 3.4.0 now support $\LaTeX$ typesetting in the Jupyter Notebook!

In [1]:
import plotly.graph_objs as go
import plotly.io as pio
In [2]:
trace1 = go.Scatter(
    x=[1, 2, 3, 4],
    y=[1, 4, 9, 16],
    name='$\\alpha_{1c} = 352 \\pm 11 \\text{ km s}^{-1}$'
)
trace2 = go.Scatter(
    x=[1, 2, 3, 4],
    y=[0.5, 2, 4.5, 8],
    name='$\\beta_{1c} = 25 \\pm 11 \\text{ km s}^{-1}$'
)
data = [trace1, trace2]
layout = go.Layout(
    title='$\LaTeX \\text{ Typesetting}$',
    xaxis=dict(
        title='$\\sqrt{(n_\\text{c}(t|{T_\\text{early}}))}$'
    ),
    yaxis=dict(
        title='$d, r \\text{ (solar radius)}$'
    )
)
fig = go.FigureWidget(data=data, layout=layout)
In [3]:
fig

It's also possible to save a figure with $\LaTeX$ typesetting to an HTML file. To do so, set the include_mathjax argument to 'cdn' in the plotly.offline.plot function

In [4]:
from plotly.offline import plot
In [5]:
plot(fig, filename='fig_with_LaTeX.html', include_mathjax='cdn')
Out[5]:
'file:///Users/jmmease/Plotly/repos/plotly.py_release_notebooks/notebooks/v3.4.0/fig_with_LaTeX.html'
In [ ]: