In my plot’s x and y axis titles, I needed to add an overline to just one character, similar to doing $[\overline{1}10]$
in LaTeX to represent [-1 1 0] (specifically, I’m wanted to add Miller indices to my axis titles). I’m having trouble getting LaTeX working in Jupyter (for both Python and Julia), but fortunately I was able to use the <span>
html tag to avoid it: e.g. <span style='text-decoration:overline'>overlined text</span>
.
e.g.
import plotly.graph_objects as go
fig = go.Figure(
data=go.Contour(
z=[
[10, 10.625, 12.5, 15.625, 20],
[5.625, 6.25, 8.125, 11.25, 15.625],
[2.5, 3.125, 5.0, 8.125, 12.5],
[0.625, 1.25, 3.125, 6.25, 10.625],
[0, 0.625, 2.5, 5.625, 10],
]
)
)
fig.update_layout(
yaxis=dict(title_text="[1<span style='text-decoration:overline'>1</span>0]"),
xaxis=dict(title_text="[<span style='text-decoration:overline'>1</span>10]"),
font=dict(size=15),
)
fig.show()
which produces
or in Julia
using PlotlyJS
p = plot(scattergl(
x=collect(1:10), y=collect(1:10),
mode="markers"
))
relayout!(
p,
yaxis=attr(title_text="[1<span style='text-decoration:overline'>1</span>0]"),
xaxis=attr(title_text="[<span style='text-decoration:overline'>1</span>10]"),
font=attr(
family="Arial",
size=21,
color="Black"
),
)
p
which produces
I was unable to find this solution online, and documentation on whether tags were supported by Plotly was hard to find, so I thought I’d put this here in case someone else has the same issue.