✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

LaTeX strings parsed in figure title, but not in axes layout

I’m trying to make a simple surface 3D plot using Plotly in python / jupyterlab (both produce the same problem). My problem is that LaTeX strings in the axis title and ticks are simply not parsed correclly, although I’m sure to have entered them correctly. This is although LaTeX strings in, by example, the overall figure title are working absolutely fine. My code is the following:

# Import the necessaries libraries
from IPython.core.display import display, HTML
import plotly.offline as pyo
# Set notebook mode to work in offline
import plotly.graph_objects as go
import numpy as np
import pandas as pd

t_2 = 1 #Hopping energy along y
t_1 = 2*t_2 #Hopping energy along x
a_x = 1 #Lattice constant along x
a_y = 3/2 * a_x #Lattice constant along y
N_x = 100 #Number of nuclei in total along x
N_y = 100 #Number of nuclei in total along y
epsilon_0 = 1 #Unit of orbital energy.

kx, ky = np.linspace(-np.pi/a_x, np.pi/a_x, N_x), np.linspace(-np.pi/a_y, np.pi/a_y, N_y)
kxv, kyv = np.meshgrid(kx, ky) #Crystal momentum in x and y direction

E = epsilon_0 - t_1*2*np.cos(kxv*a_x) - t_2*2*np.cos(kyv*a_y) #Energy of the system as function of indep. var. crystal momentum k


fig = go.Figure(data=[go.Surface(z=E, x=kx, y=ky)])
fig.update_traces(contours_z=dict(show=True, usecolormap=True,
                                  highlightcolor="limegreen", project_z=True))
fig.update_layout(title=r'$-\frac{\pi}{a_x}$', autosize=False,
                     ticktext=[r'$-\frac{\pi}{a_x}$', r"$-\frac{\pi}{2a_x}$", "0", r"$\frac{\pi}{2a_x}$", r"$\frac{\pi}{a_x}$"],
                     tickvals=[-np.pi/a_x, -np.pi/(2*a_x), 0, np.pi/(2*a_x), np.pi/a_x],
                     title_text="$\\tan(\\nu\\cdot x)$",
                     ticktext=[r'$-\frac{\pi}{a_y}$', r"$-\frac{\pi}{2a_y}$", "0", r"$\frac{\pi}{2a_y}$", r"$\frac{\pi}{a_y}$"],
                     tickvals=[-np.pi/a_y, -np.pi/(2*a_y), 0, np.pi/(2*a_y), np.pi/a_y],
                  scene_camera_eye=dict(x=1.87, y=0.88, z=0.64),
                  width=800, height=700,
                  #margin=dict(l=65, r=50, b=65, t=90),


The resulting figure looks:

Note that using offline mode, or working in jupyterlab is definitely NOT the problem, since doing the equivalent in pure python in online mode of plotly gives exactly the same.

Hope someone has some experience with this issue. Any help is welcome!