Skip to content
Snippets Groups Projects
Commit 25356df7 authored by Subrahmanyam Pottimurthi's avatar Subrahmanyam Pottimurthi
Browse files

Revert "Dummy dataset Vis tech2 with plots"

This reverts commit 9c734169
parent 1f1b9aa3
No related branches found
No related tags found
No related merge requests found
Date InfectedCases C1_School closing C2_Workplace closing C3_Cancel public events C4_Restrictions on gatherings C5_Close public transport C6_Stay at home requirements C7_Restrictions on internal movement, C8_International travel controls
2020-04-01 100,00 0 0 0 0 0 0 0 0
2020-04-02 1000,00 0 0 0 0 0 0 0 0
2020-04-03 10000,00 0 0 0 0 0 3 0 0
2020-04-04 50000,00 0 0 0 4 2 3 2 0
2020-04-05 25000,00 3 0 0 4 2 3 2 2
2020-04-06 10000,00 3 2 2 4 2 2 2 4
2020-04-07 5000,00 3 3 2 0 0 2 2 4
2020-04-08 2000,00 3 3 0 0 0 2 2 4
import numpy as np
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import pandas as pd
def plotFun(selectionList):
data_idv = pd.read_csv('idv1.txt', sep='\t')
line = data_idv.iloc[:, 0:2]
data_idv = data_idv.set_index('Date')
# data_idv
data_idv = data_idv.iloc[:, 1:]
data_idv = data_idv.astype(int)
data_idv = data_idv.transpose()
# data_idv
policy = data_idv.index
dates = data_idv.columns
dates = np.array(dates)
# print(dates)
if selectionList:
policy = np.array(selectionList)
else:
policy = np.array(policy)
# print(policy)
df = pd.read_csv('idv1.txt', sep='\t')
# Create figure with secondary y-axis
fign = make_subplots(specs=[[{"secondary_y": True}]])
# Add traces
fign.add_trace(
go.Scatter(x=df['Date'], y=df['InfectedCases'], name="Infected Cases"),
secondary_y=False,
)
fign.add_trace(
go.Heatmap(
z=data_idv,
x=dates,
y=policy,
colorscale='Viridis'),
secondary_y=True,
)
# Add figure title
fign.update_layout(
title_text="Double Y Axis Example"
)
# fign.update_layout(barmode='stack')
# Set x-axis title
fign.update_xaxes(title_text="xaxis title")
# Set y-axes titles
fign.update_yaxes(title_text="<b>primary</b> yaxis title", secondary_y=False)
fign.update_yaxes(title_text="<b>secondary</b> yaxis title", secondary_y=True)
# Add range slider
fign.update_layout(
xaxis=dict(
rangeselector=dict(
buttons=list([
dict(count=1,
label="1m",
step="month",
stepmode="backward"),
dict(count=6,
label="6m",
step="month",
stepmode="backward"),
dict(count=1,
label="YTD",
step="year",
stepmode="todate"),
dict(count=1,
label="1y",
step="year",
stepmode="backward"),
dict(step="all")
])
),
rangeslider=dict(
visible=True
),
type="date"
)
)
# fign.show()
return fign
if __name__ == '__main__':
plotFun()
\ No newline at end of file
import dash
import dash_html_components as html
import dash_core_components as dcc
import plots
import pandas as pd
import numpy as np
from dash.dependencies import Input, Output
data_idv = pd.read_csv('idv1.txt', sep='\t')
line = data_idv.iloc[:, 0:2]
data_idv = data_idv.set_index('Date')
data_idv
data_idv = data_idv.iloc[:, 1:]
data_idv = data_idv.astype(int)
data_idv = data_idv.transpose()
data_idv
policy = data_idv.index
dates = data_idv.columns
dates = np.array(dates)
print(dates)
policy = np.array(policy)
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
html.Div([
dcc.Tabs([
dcc.Tab(label='Tab one', children=[
dcc.Graph(
figure={
'data': [
{'x': [1, 2, 3], 'y': [4, 1, 2],
'type': 'bar', 'name': 'SF'},
{'x': [1, 2, 3], 'y': [2, 4, 5],
'type': 'bar', 'name': u'Montréal'},
]
}
)
]),
html.Div([
dcc.Tab(label='Tab two', children=[
html.Div([
dcc.Graph(
id = 'vis2'
# figure=plots.plotFun()
),
]),
dcc.Checklist(
id = 'my_list',
options=[
{'label': x, 'value': x, 'disabled':False}
for x in policy
],
value=[x for x in policy], # values chosen by default
className='my_box_container', # class of the container (div)
# style={'display':'flex'}, # style of the container (div)
inputClassName='my_box_input', # class of the <input> checkbox element
# inputStyle={'cursor':'pointer'}, # style of the <input> checkbox element
labelClassName='my_box_label', # class of the <label> that wraps the checkbox input and the option's label
# labelStyle={'background':'#A5D6A7', # style of the <label> that wraps the checkbox input and the option's label
# 'padding':'0.5rem 1rem',
# 'border-radius':'0.5rem'},
#persistence='', # stores user's changes to dropdown in memory ( I go over this in detail in Dropdown video: https://youtu.be/UYH_dNSX1DM )
#persistence_type='', # stores user's changes to dropdown in memory ( I go over this in detail in Dropdown video: https://youtu.be/UYH_dNSX1DM )
),
]),
]),
]),
]),
])
@app.callback(Output('vis2', 'figure'),
[Input('my_list', 'value')])
def options(list):
return plots.plotFun(list)
if __name__ == '__main__':
app.run_server(debug=False)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment