Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Multiple Lines on the Same Plot Using hvplot

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

!curl -sSL -o loss.csv https://github.com/dclong/blog/files/7229259/loss.csv
import pandas as pd
import hvplot.pandas
Loading...
Loading...
Loading...
df = pd.read_csv("loss.csv")
df
Loading...

Manually Overlay Multiple Plots

This way is good for creating subplots but is not suggested for overlaying multiple plots into one plot as you will have to do extra work to label lines.

df.hvplot.line("Step", "Value_train") + df.hvplot.line("Step", "Value_train")
Loading...
df.hvplot.line("Step", "Value_train") * df.hvplot.line("Step", "Value_train")
Loading...

groupby + overlay

This approach is best for slim-and-tall data.

df2 = df.melt(id_vars="Step", value_vars=["Value_train", "Value_test"])
df2
Loading...
df2.hvplot.line("Step", "value", groupby="variable")
Loading...
df2.hvplot.line("Step", "value", groupby="variable").overlay()
Loading...

Direct Specify Multiple y-Columns

df.hvplot.line("Step", ("Value_train", "Value_test"))
Loading...