I’m trying to create a graph that consists of two-charts-in-one, i.e. one x-axis with two y-axes. One graph is static, a (go.Figure) the other changes using sliders in a callback function(dcc.Graph). For example, the first graph could be environmental data from a csv file with the y-axis on the left and the second a sine wave — y-axis on the right — that can change amplitude, phase, frequency through the use of sliders.
——————Situation now; this works——————
y1______________
| |
| graph 1 |
||
x-axis
y2
| |
| graph 2 |
|______________|
x-axis
—————|————Amp
———|——————Phase
———————|——Freq
sliders(callback)
—————Situation wanted; can’t get it to work——————
y1______________y2
| |
| graph 1 + 2 |
|_______________ |
shared x-axes
—————|————Amp
———|——————Phase
———————|——Freq
sliders(callback)
I can’t get this to work; is there an example somewhere that I could use that anyone knows off? Below the code. Thanks in advance.
from dash_core_components.Graph import Graph
import numpy as np
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.express as px
import pandas as pd
import plotly.graph_objects as go
app = dash.Dash(__name__)
# Prepare the asset chart
df = pd.read_csv("Environment.csv")
df.head()
df['date'] = pd.to_datetime(df['date'])
fig = go.Figure(data=go.Line(x=df['date'], y=df['Temp']))
fig.update_yaxes(type="log")
fig.update_layout(
xaxis=dict(
rangeslider=dict(
visible=False
)
)
)
app.layout = html.Div(
children=[
html.Div([
dcc.Graph(id='environ-graph', figure=fig),
dcc.Graph(id="wave")
]),
html.Div([
html.Label("Frequency 1"),
dcc.Slider(id='f1',
min=0.0006,
max=0.0008,
value=0.0007456,
step=0.00001)
- -------etc-----