Hello everyone !
I have write a code in python to plot data from different brain’s areas at different time and I’m new to plotly.
I would like to trace the different graphics and for each a brain’s area as function of the time with dropdown .
> Brains Jour T1_Thalamus ... T2_Thalamus T2_CC T2_Isocortex
0 101 0 1069.0 ... 54.0 54.0 63.0
1 101 1 185.0 ... 41.0 36.0 36.0
2 101 3 116.0 ... 33.0 32.0 35.0
Here is my code, I know it doesn’t work but I don’t understand the dropdown function :
mport plotly.express as px
import pandas as pd
df = pd.read_csv("Données_INC.csv", sep=";")
print(df)
df['Brains'] = df.Brains.astype(object)
fig1 = px.line(df, x=df.Jour, y=df.T1_Thalamus, color=df.Brains, markers=True)
fig1.update_traces(marker={'size': 15})
fig2 = px.line(df, x=df.Jour, y=df.T1_CC, color=df.Brains, markers=True)
fig2.update_traces(marker={'size': 15})
updatemenus = [
{'buttons': [
{
'method': 'restyle',
'label': 'T1 Thalamus',
'args': [{'y': [df.T1_Thalamus]}]
},
{
'method': 'restyle',
'label': 'T1 Corps calleux',
'args': [{'y': [df.T1_CC]},
{'x': [df.Jour]}],
}
],
'direction': 'down',
'showactive': True,}
]
fig = fig1.update_layout(
updatemenus=updatemenus,
showlegend=False)
fig = fig.update_traces()
fig.show()
Thank you so much <3