Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Import Jupyter Code to Dash app. Can't run Jupyter code on Dash app!

Hi there.

I have created this working Jupyter code which works flawlessly with plotly offline mode.

import pandas as pd
import plotly as py
import numpy as np
import plotly.graph_objs as go
import ipywidgets as widgets
import numpy as np
from scipy import special

df=pd.read_csv(‘treat_all2.csv’)

py.offline.init_notebook_mode(connected=True)

trace1=go.Scatter(
x=df[‘date’],
y=df[‘count’],
name=‘Performance X’
)

trace2=go.Scatter(
x=df[‘date’],
y=df[‘idade’],
name=‘LFTU/day’,
xaxis=‘Performance Y’
)

data=[trace1,trace2]
layout=go.Layout(

plot_bgcolor='#D9E0EC',
title='Performance Analysis',
xaxis=dict(
    title='Analysis X',
    tickangle=45,
    ticklen=5,
    gridwidth=2,
    showticklabels=True,
    nticks=3,
),
yaxis=dict(
    title='Analysis Y',
    ticklen=5,
    gridwidth=2,
),

)

fig=go.Figure(data=data, layout=layout)

py.offline.iplot(fig, filename=‘style-scatter’)

But I don’t know how to export this Jupyter code to Dash app. I want this Scatter plot on my Dash app. Please, help me solve this.

Thanks.

@MGBpy