Hi @Conor ,
As far as I know, that feature is not available in built-in right now.
But it does not mean impossible.
The possible solution that came up into my mind is by creating 2 same plot objects , Scatter as example.
After that, by using those 2 plot objects you can :
- set the first plot to display the colorbar with reverse range color scale using
labelalias
attribute.
- the second plot has role to show the trace only. You need to reverse the colorscale using
reversescale=True
and hide the colorbar of second plot using showscale=False
.
Here the code of those scenario
import plotly.graph_objects as go
import numpy as np
y_data = [10,20,30,40,50,60,70,80,90,100]
x_data = [10,20,30,40,50,60,70,80,90,100]
tickvals = [0, 25, 50, 75, 100]
reverse_labelalias = dict([(k,str(v)) for k,v in zip(tickvals,sorted(tickvals, reverse=True))])
fig = go.Figure(data=[
# First plot to show the colorbar only
go.Scatter(
y = y_data,
x = x_data,
mode='markers',
name='',
marker=dict(
size=16,
color=y_data,
showscale=True,
colorbar=dict(
title="Rank",
tickmode="array",
tickvals= tickvals,
labelalias= reverse_labelalias,
)
)
),
# Second plot to show the trace only
go.Scatter(
y = y_data,
x = x_data,
mode='markers',
name='Rank',
marker=dict(
size=16,
color=y_data,
reversescale=True,
showscale=False,
colorbar=dict(
title="Rank",
tickmode="array",
)
)
)
]
)
fig.update_layout(showlegend=False, title="Reverse Range Scale")
fig.show()
Hope this help you.