I have a 2d list and I want to create a Plotly multi-line chart to represent this data.
So far I've got this code:
print(len(conv_loss),len(conv_loss[0]))
print(np.array(conv_loss).shape)
conv_loss_df = pd.DataFrame(data=conv_loss, index=namelist, columns=rs)
print(conv_loss_df)
which outputs:
4 10
(4, 10)
0.0 0.1 0.2 ... 0.7 0.8 0.9
mnist 0.020498 0.123125 0.222588 ... 1.122625 1.387823 1.701249
fashion_mnist 0.232772 0.316569 0.433325 ... 1.281240 1.545556 1.830893
cifar10 0.957889 0.851946 0.921106 ... 1.645510 1.815194 2.104631
cifar100 3.516734 3.052485 3.021778 ... 3.688753 3.937770 4.599526
I would want the chart to have the x axis be rs
, the colors be namelist
and the y axis be the respective data itself.
I have played around with the examples they give for plotly line charts but I just can't seem to get it to work.
The way I've got to work it to not error is:
fig = px.line(conv_loss_df,x=rs)
fig.show()
The desired graph can be drawn by targeting the data frame with the given data transposed. This was created with sample data.