I am building a dashboard on dash plotly that will have multiple x features in a single scatter plot, with each feature either being presented as a line or a line with markers.
I have built a scatter plot according to the requirements I have specified however, when I run my dashboard locally I do not actually see the scatter plot
This is the code I have written
import dash
import dash_table
import plotly.graph_objs as go
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Input,Output
import pandas as pd
import os
import numpy as np
app = dash.Dash()
app.layout = html.Div(children=[
dcc.Graph(
id='supervisor'
)
])
@app.callback(dash.dependencies.Output('supervisor','figure'))
def scattertable():
trace0 = go.Scatter(
x=supervisor['Características (D)'],
y=supervisor['Mean Team Performance'],
mode='lines',
name='Caracteristicas (D)'
)
trace1 = go.Scatter(
x=supervisor['Características (I)'],
y=supervisor['Mean Team Performance'],
mode='lines+markers',
name='Características (I)'
)
trace2 = go.Scatter(
x=supervisor['Características (S)'],
y=supervisor['Mean Team Performance'],
mode='lines',
name='Características (S)'
)
trace3 = go.Scatter(
x=supervisor['Características (C)'],
y=supervisor['Mean Team Performance'],
mode='lines+markers',
name='Características (C)'
)
data = [trace0,trace1,trace2,trace3]
return {"data": data,
"layout": go.Layout(title="Relationship",
yaxis={"title":'Mean', "range":[0, max(supervisor['Mean Team Performance'])+1]},
xaxis={"title":'Characteristics', "tickangle":45}, )}
if __name__ == '__main__':
app.run_server(debug=True)
This is a sample of my data
{'Características (D)': {2373: nan, 2361: 67.0, 2349: 65.0},
'Características (I)': {2373: nan, 2361: 20.0, 2349: 55.0},
'Características (S)': {2373: nan, 2361: 48.0, 2349: 30.0},
'Características (C)': {2373: nan, 2361: 90.0, 2349: 85.0},
'Motivación (D)': {2373: nan, 2361: 69.0, 2349: 59.0},
'Motivación (I)': {2373: nan, 2361: 25.0, 2349: 58.0},
'Motivación (S)': {2373: nan, 2361: 65.0, 2349: 30.0},
'Motivación (C)': {2373: nan, 2361: 84.0, 2349: 93.0},
'Bajo Stress (D)': {2373: nan, 2361: 69.0, 2349: 69.0},
'Bajo Stress (I)': {2373: nan, 2361: 30.0, 2349: 60.0},
'Bajo Stress (S)': {2373: nan, 2361: 40.0, 2349: 40.0},
'Bajo Stress (C)': {2373: nan, 2361: 92.0, 2349: 74.0},
'Cost to Company': {2373: 1908.33, 2361: 1908.33, 2349: 1908.33},
'MonthsofEmploymentRounded': {2373: 1.0, 2361: 4.0, 2349: 4.0},
'Compensation': {2373: 1200.0, 2361: 1200.0, 2349: 1200.0},
'span': {2373: 37.0, 2361: 58.0, 2349: 86.0},
'Mean Team Performance': {2373: 0.40544395205206984,
2361: 0.5936947689016717,
2349: 0.5403025332663768},
'Mean Team Employment in Months': {2373: 8.675675675675675,
2361: 5.396551724137931,
2349: 6.174418604651163},
'employment span': {2373: 43, 2361: 128, 2349: 128}
}