Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

plotly dcc.interval bar graph with time

import dash
from dash.dependencies import Output, Event
import dash_core_components as dcc
import dash_html_components as html
from random import random
import plotly

app = dash.Dash(__name__)
app.layout = html.Div(
    html.Div([
        dcc.Graph(id='live-update-graph-scatter', animate=True),
        dcc.Graph(id='live-update-graph-bar'),
        dcc.Interval(
            id='interval-component',
            interval=1*1000
        )
    ])
)


@app.callback(Output('live-update-graph-scatter', 'figure'),
              events=[Event('interval-component', 'interval')])
def update_graph_scatter():

    traces = list()
    for t in range(2):
        traces.append(plotly.graph_objs.Scatter(
            x=[1, 2, 3, 4, 5],
            y=[(t + 1) * random() for i in range(5)],
            name='Scatter {}'.format(t),
            mode= 'lines+markers'
            ))
    return {'data': traces}

@app.callback(Output('live-update-graph-bar', 'figure'),
              events=[Event('interval-component', 'interval')])
def update_graph_bar():

    traces = list()
    for t in range(2):
        traces.append(plotly.graph_objs.Bar(
            x=[1, 2, 3, 4, 5],
            y=[(t + 1) * random() for i in range(5)],
            name='Bar {}'.format(t)
            ))
    layout = plotly.graph_objs.Layout(
    barmode='group'
)
    return {'data': traces, 'layout': layout}


if __name__ == '__main__':
    app.run_server(debug=True)
Comment

PREVIOUS NEXT
Code Example
Python :: Redirect to same page after POST method using class based views 
Python :: install requests-html modlule click on the link to learn more about requests-html 
Python :: quadkey calculator 
Python :: python mod of list numpy 
Python :: Realtime-yahoo-stock_price 
Python :: python weekly aggreation string time 
Python :: load shapefile fiona multiline intersection 
Python :: splitting Feature and target using iloc 
Python :: Insertion Sorting using while in python 
Python :: pyttsx3 listen to events 
Python :: custom port odoo 
Python :: how to un register DefaultAdminSite in django 
Python :: Flatten List in Python Using NumPy Ravel 
Python :: Grading program using if else 
Python :: python create named timer 
Python :: Add 1 to loops 
Python :: godot get the closer node from array 
Python :: python sqlite select where 
Python :: counter and element of list for loop python 
Python :: keyword only arguments python 
Python :: block size explained in python hashlib module 
Python :: kaggle replace 
Python :: Python NumPy vstack Function Example with 1d array 
Python :: How can I Duplicate 1 Dimensional array 
Python :: Python __le__ 
Python :: p0, percent, aug (inhabitants coming or leaving each year), p (population to surpass) 
Python :: NumPy right_shift Code When inputs and bit shift are an arrays 
Python :: how to separate data from two forms in django 
Python :: how to use python telegram filters 
Python :: QDateEdit.date().toString("MMMM dd, yyyy") does not display months in English 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =