I have a heatmap with custom ticks (custom location and custom label). I would like the label to appear in between ticks. So far I managed to get this:
import numpy as np
import plotly.graph_objects as go
np.random.seed(13)
N = 100
M = 30
ticks = ['alpha', 'beta', 'gamma', 'zeta', 'theta', 'lambda']
ticks_locations = [0] + np.sort(np.random.randint(0, N, size=len(ticks)-1)).tolist()
image = np.random.randn(M, N)
fig = go.Figure(data=
go.Heatmap(
x=np.arange(N) + .5,
z=image,
colorscale='Bluered',
)
)
fig.update_xaxes(
tickvals=ticks_locations,
ticktext=ticks,
ticklen=20,
tickcolor='black',
ticks='outside',
ticklabelposition='outside right',
# tickson='boundaries',
)
fig.write_html('/tmp/tmp.html')
However, I would like my labels to appear in the middle in between the ticks (alpha
between the first and the second tick, beta
between the second and the third, and so onβ¦).
Each label corresponds to a range of columns in the heatmap. When I zoom on the x-axis, I would like at least one tick to stay visible no matter the zoom level. More specifically, I would like to reproduce the behaviour of the outer labels (first
and second
) in multi-category axis: when you zoom on the x-axis, the outer label moves to stay visible on the axis.
I tried to play around with tickson='boundaries'
but I was not able to get it to work.