I would like to have several plots which share the same x-axis (which is time). I got it somehow working by using , facet_row = 'variable'
but this doesn’t allow e.g. different zooms on y
. I need to zoom into the data in x
and y
for all four variables. The x-axis
should always be in sync for all four plots / variables but y-axis
should be independent.
Is this somehow possible?
Here is the code:
df2 = df.melt(id_vars=['Device','time'], value_vars=['V+','V-','I_A', 'I_fil'])
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, title='Dashboard', external_stylesheets=external_stylesheets)
colors = {
'background': '#000000',
'text': '#f3ff00'
}
app.layout = html.Div(children = [
html.Div([
html.H4('Dauertest'),
html.Div(children = ""),
dcc.Graph(id = 'General'
, figure={}
),
]),
dcc.Checklist(
id="signals",
options = ['V+', 'V-', 'I_A', 'I_fil',],
value = ['V+', 'V-', 'I_A'],
inline=True
),
html.Br(),
html.Br(),
# New row
html.Div([
html.Div([
dcc.Graph(id = 'shared'
, figure={}
),
], className='twelve columns'),
], className='row'),
html.Br(),
])
@app.callback(
Output("General", "figure"),
Output("shared", "figure"),
Input("signals", "value")
)
def update_line_chart(signals):
df3=df2[df2['variable'].isin(signals)]
fig_general = px.scatter(df3
, x = "time"
, y = 'value'
, color = 'Device'
, symbol = 'variable'
, hover_name = "Device"
, template = 'plotly_dark'
).update_layout(
transition_duration = 500
, autosize = True
, height = 700
)
fig_shared = px.scatter(df3
, x = "time"
, y = "value"
, color = 'Device'
, hover_name = "Device"
, template = 'plotly_dark'
, facet_row = 'variable'
,
).update_layout(
transition_duration = 500
, autosize = True
, height = 1000
)
return [fig_general, fig_shared]
# Run the app
if __name__ == "__main__":
app.run_server(debug=False, port=8050)
and here the data: Filebin | pag2dnsixti4ce9a