Hi I am wondering how to give a label name when using plotly express where the data is not in the form of a DataFrame
. Its not possible to use the keyword argument name
when using px.line
. However it is a possible when using px.scatter
function.
As a result in the example below I end up with a legend name only for the second trace.
I am aware this can be easily done using plotly.graph_objs
but wondering how to do in plotly.express
import plotly.express as px
history_dict = history.history
p1 = px.line(
x = np.arange(0,20),
y = history_dict["loss"],
# error if name keyword argument used here.
title = "Training and Validation Loss",
)
p1.add_scatter(
x = np.arange(0,20),
y = history_dict["val_loss"],
mode = "lines",
name = "val loss"
)
p1.update_layout(xaxis_title = "epochs", yaxis_title = "loss")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.