Hello @clairew,
In order to reverse the ticklabels on the colorbar, as well as the information to be displayed
on hover, we define a function that maps the interval [a,b], onto [b,a]: f(t, a, b)=b+a-t.
import plotly.graph_objects as go
import numpy as np
# function to reverse z-values to be displayed on hover, and on colorbar
f=lambda t, a, b :b+a-t
z= np.array([[2, 3, 5, 7],
[6, 2, 0, -1],
[4, 3, 1, 6],
[1, -2, 3, 4]])
a, b = z.min(), z.max()
fig=go.Figure(go.Heatmap(z=z, colorscale="matter", colorbar_thickness=24,
colorbar_tickvals=[-2, 1, 4, 7],
colorbar_ticktext=f([-2, 1, 4, 7], a, b),
customdata=f(z, a, b), hovertemplate='z: %{customdata}<extra></extra>'
),
go.Layout(width=400, height=400, yaxis_scaleratio=1, yaxis_scaleanchor="x",
template="none", yaxis_zeroline=False, xaxis_zeroline=False))