0
I trying to create a multiple line charts where have one line for each machine and ‘Time’ in on X axis. However I tried a lot of combinations to generate X and Y label. The more closer that I git from expected result is chart below.
- All Advises are welcome.
This is the dataframe.
df3:
Machine Units Pruduced Time
K2K02 1900 15
K2K03 311 15
K2K01 5230 17
K2K02 1096 12
K2K03 1082 11
K2K07 587 17...
So i Grouping and unstacking to prepare df to plot graph.
fdr = dff3.groupby(['Time', 'Machine']).sum()
fdr2 = fdr.unstack('Time')
fdr2
This is my code:
import dash_table_experiments
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import plotly.graph_objects as go
import numpy as np
import dash_table_experiments as dash_table
import dash
from dash.dependencies import Input, Output
import dash_table
import pandas as pd
import plotly_express as px
import plotly.offline as pyo
dff3 = pd.read_csv('df3.csv', encoding='latin-1', low_memory=False)
dff3
fdr = dff3.groupby(['Time', 'Machine']).sum()
fdr2 = fdr.unstack('Time')
fdr2
app = dash.Dash()
app.layout = html.Div([
dcc.Graph(
id = 'GrapGo',
figure = {
'data' : [
go.Scatter(
x = fdr2.index,
y = fdr2.loc[rowname],
mode = "markers+lines",
name = rowname
)for rowname in fdr2.index
],
'layout' : go.Layout(
title = "Grafico com go",
xaxis = {'title': 'X Label'},
yaxis = {'title': 'y Label'}
)
}
)
])
if __name__ == '__main__':
app.run_server()
This is graph i getting.
The expected result is: