You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following code I created a simple plot with a dropdown menu where each button is expected to modify the colorscale. However, some of these don't seem to work properly and when the corresponding button is clicked, a default colorscale is applied instead.
import plotly.graph_objects as go
import numpy as np
# Generate sample data
np.random.seed(42)
x = np.random.rand(100)
y = np.random.rand(100)
z = np.sqrt(x**2 + y**2)
# Available colormaps
colorscales = ['Viridis', 'Cividis', 'Plasma', 'Inferno', 'Magma']
# Create the initial figure with one colorscale
scatter = go.Scatter(
x=x,
y=y,
mode='markers',
marker=dict(
size=10,
color=z,
colorscale=colorscales[0],
colorbar=dict(title='Value'),
showscale=True
)
)
fig = go.Figure(data=[scatter])
# Add dropdown menu
fig.update_layout(
updatemenus=[
dict(
buttons=[
dict(
label=scale,
method='restyle',
args=[{'marker.colorscale': [scale]}]
)
for scale in colorscales
],
direction='down',
showactive=True,
x=1.1,
y=1
)
],
title="Scatter Plot with Colormap Dropdown",
xaxis_title="X",
yaxis_title="Y"
)
fig.show()
In this plot only 'Viridis' and 'Cividis' colorscales are supported. More in general it seems to me that the only supported ones are those defined in plotly.colors.plotlyjs (only the non-reversed ones).
The text was updated successfully, but these errors were encountered:
In the following code I created a simple plot with a dropdown menu where each button is expected to modify the colorscale. However, some of these don't seem to work properly and when the corresponding button is clicked, a default colorscale is applied instead.
In this plot only
'Viridis'
and'Cividis'
colorscales are supported. More in general it seems to me that the only supported ones are those defined inplotly.colors.plotlyjs
(only the non-reversed ones).The text was updated successfully, but these errors were encountered: