[Solved] Dash Python how to make multiple updating graphs, how to title

Dan Muller Asks: Dash Python how to make multiple updating graphs, how to title
new coder here, I’m trying to make 4 graphs that share the same random data (although I plan on splitting them apart later). When it was just the one graph it took the random data fine and automatically scaled. In the go.layout there’s no way to put which graph you’re labeling. Now that I’ve added multiple none of them have any titles, axis labels, or data. Please help!

Code:
import dash
from dash.dependencies import Output, Input
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import random
import plotly.graph_objs as go
from collections import deque
#setting first points
X = deque(maxlen = 20)
X.append(1)
Y = deque(maxlen = 20)
Y.append(1)
#app settings, html layout
app = dash.Dash(__name__)
  
app.layout = html.Div(children=[
    html.H1([
        html.H1(children='Graphs'),
        dcc.Graph(id = 'Battery Voltage', animate = True),
        dcc.Interval(
            id = 'graph-update',
            interval = 1000,
            n_intervals = 0
        ),
    ],
),
html.Div(
    [
        dcc.Graph(id = 'Signal', animate = True),
        dcc.Interval(
            id = 'graph-update2',
            interval = 1000,
            n_intervals = 0
        ),
    ],
),
html.Div(
    [
        dcc.Graph(id = 'Health', animate = True),
        dcc.Interval(
            id = 'graph-update3',
            interval = 1000,
            n_intervals = 0
        ),
    ],
),
html.Div(
    [
        dcc.Graph(id = 'Prognastics', animate = True),
        dcc.Interval(
            id = 'graph-update4',
            interval = 1000,
            n_intervals = 0
        ),
    ],
)])

#this is what keeps the graph updating 
@app.callback(
    [Output('Battery Voltage', 'figure'),
     Output('Signal', 'figure'),
     Output('Health', 'figure'),
     Output('Prognastics', 'figure')],
    [ Input('graph-update', 'n_intervals'),
      Input('graph-update2', 'n_intervals'),
      Input('graph-update3', 'n_intervals'),
      Input('graph-update4', 'n_intervals')]
)
  
def update_graph_scatter(n):

    X.append(X[-1]+1)
    Y.append(Y[-1]+Y[-1] * random.uniform(-0.1,0.1))
    data = go.Scatter(
            x=list(X),
            y=list(Y),
            name='Scatter',
            mode= 'lines+markers'
    )
  
    return {'data': [data],
            'layout' : go.Layout(title="Battery Voltage",
                                 xaxis_title="Time",
                                 yaxis_title="Voltage",
                                 xaxis=dict(range=[min(X),max(X)]),
                                 yaxis = dict(range = [min(Y),max(Y)])
                                 )
            }

if __name__ == '__main__':
    app.run_server()

When ran with multiple

Just the one

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.