0

I have a Seaborn line plot and I would like to add a single dotted line that represents the 'baseline' value to the plot (y=50). Currently I just have

sns.lineplot(data=df, x=df.index, y="Average Score")

and it looks like a normal line plot.

I was thinking of something along the lines of adding a column to my Pandas dataframe that has all values equal to 50 and then including it in the hue somehow?

Redox
  • 9,321
  • 5
  • 9
  • 26
em1234x
  • 11
  • 2

1 Answers1

0

If you are looking to add a horizontal line to the lineplot, the easier way would be to use matplotlib's axhline(). An example is shown below. Hope this is what you are looking for...

df=pd.DataFrame()
df['Average Score'] = [random.uniform(30, 70) for n in range(200)]
ax=sns.lineplot(data=df, x=df.index, y="Average Score")
ax.axhline(y=50, linewidth=2, color='orange', ls=':')

enter image description here

Redox
  • 9,321
  • 5
  • 9
  • 26