Custom tick labels in between ticks on heatmap

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

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=
        x=np.arange(N) + .5,

    ticklabelposition='outside right',
    # tickson='boundaries',


attempt so far

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.



To move ticklabels to the right, you must change the values in tickvals, something like this:
tickvals=np.array(ticks_locations[:-1]) +a
where a is an array with a[i], the mid point between ticks_locations[i] and ticks_locations[i+1], i=0, 1, … len(ticks_locations)-1.

1 Like

This would also shift the tick right? I would like to only shift the label, and let the ticks where they are. Something like that:

|      alpha      |                beta                |   gamma   |      zeta      |...

@josephlegrand33 This isn’t possible.

1 Like

Thank you. It is unfortunate tho as it has been implemented for multi-categorcal axes

For multicategory axes see here:Categorical axes in Python

Well that’s exactly the link I included in the original post