Open filipesmg opened 2 years ago
This seems to be an issue specific to that example, as just creating a trace with one of those colorscales works as intended."Blues" and "Greens" are actually the ones getting inverted.
Smaller reproducible example:
import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(go.Heatmap(z=[[i for i in range(10)]], colorscale="Blues"))
fig.update_layout(
updatemenus=[
dict(
buttons=list([
dict(
args=["colorscale", "Blues"],
label="Blues",
method="restyle"
),
dict(
args=["colorscale", "Reds"],
label="Reds",
method="restyle"
)
]),
),
]
)
fig.show()
@alexcjohnson is this a plotly.js
issue?
To start, the "Blues" colorscale is displayed correctly, as is the "Reds" if selected. But switching back from "Reds" to "Blues" somehow causes the colorscale to reverse.
Codepen if that's helpful: https://codepen.io/aaronstiff/pen/qBMzNjB
I think the problem is that the args
are interpreted 100% in Plotly.js which (awkwardly!) has its own definitions of colorscales, some of which share names with the Python ones (Reds, Blues) but maybe not orientations, and it's missing a whole bunch of the Python ones (Turbo, Inferno). If you try something like args=["colorscale", plotly.colors.sequential.Reds],
I suspect you will get what you're looking for.
So this isn't so much a Plotly.py or Plotly.js issue but an impedance mismatch between the two.
Ah, I see.
However, giving colorscale
the full reference to a colorscale results in similarly odd behaviour: switching to plotly.colors.sequential.Reds
applies something that looks like RdBu
, and switching back to plotly.colors.sequential.Blues
does not change anything (still RdBu
)
There seems to be an issue with the "Reds" and "Turbo" colorscales. I couldn't find an existing issue about this, so here is how to reproduce: I just got this example from plotly page: https://plotly.com/python/dropdowns/#update-several-data-attributes And added the "Reds" and "Turbo" colorscales.
The "Reds" seem to work, but it is inverted when comparing to the "Blues" and "Greens":
The "Turbo", on the other hand, shows up like a "coolwarm" colorscale instead:
These two are different than the ones described on the documentation here: https://plotly.com/python/builtin-colorscales/#builtin-sequential-color-scales
I had similar issues when using "Plotly.update" with plotly.js to update the coloscales.
edit: Also the "Inferno" shows as the "coolwarm" one:
Probably there are others too.