plotly.py 3.4.0 now support $\LaTeX$ typesetting in the Jupyter Notebook!
import plotly.graph_objs as go
import plotly.io as pio
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)
fig
FigureWidget({ 'data': [{'name': '$\\alpha_{1c} = 352 \\pm 11 \\text{ km s}^{-1}$', 'type': …
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
from plotly.offline import plot
plot(fig, filename='fig_with_LaTeX.html', include_mathjax='cdn')
'file:///Users/jmmease/Plotly/repos/plotly.py_release_notebooks/notebooks/v3.4.0/fig_with_LaTeX.html'