I create a Ridgeplot in plotly with go.Violin.
This works but now i want to change the data of each trace with a button.
update_data1= [df1[column] for column in df1]
buttons=list([
dict(
args={'x':update_data1},
label="Datum",
method="update"
I think that when I transfer a list in args each element of the list is for one trace. Am I right? But I recive an error Message like:
Invalid value of type 'builtins.dict' received for the 'args' property of layout.updatemenu.button
Received value: {'x': [0 -1.640952
1 -1.213015
2 -0.616920
3 0.235814
4 -1.712792
95 0.003820
96 -1.021538
97 -0.948742
98 0.469165
99 -0.188269
Name: 0, Length: 100, dtype: float64, 0 2.615372
1 0.126785
2 -0.343699
3 -1.759919
4 0.992361
95 -3.424589
96 -1.950416
97 1.459593
98 -0.433436
99 0.885371
Name: 1, Length: 100, dtype: float64]}
The 'args' property is an info array that may be specified as:
* a list or tuple of up to 3 elements where:
(0) The 'args[0]' property accepts values of any type
(1) The 'args[1]' property accepts values of any type
(2) The 'args[2]' property accepts values of any type
Does anybody know what Iām doing wrong?
Code Example:
# Data handling
import numpy as np
import pandas as pd
from pathlib import Path
#Plotly
import plotly.graph_objects as go
from plotly.offline import plot
html_path=Path('Test.html')
df1=pd.DataFrame([np.random.normal(loc=0.0, scale=1.0, size=(100)),
np.random.normal(loc=0.0, scale=1.5, size=(100))
]).T
df2=pd.DataFrame([np.random.normal(loc=0.0, scale=1.0, size=(100)),
np.random.normal(loc=0.0, scale=1.5, size=(100))
]).T
fig_ridge = go.Figure()
for column in df1:
fig_ridge.add_trace(go.Violin(x=df1[column]))
fig_ridge.update_traces(orientation='h',
side='positive',
width=3,
points=False,
meanline_visible=True)
update_data1= [df1[column] for column in df1]
update_data2= [df2[column] for column in df2]