0

I would like to add a mean line of the "DP inlet" within the sns plot. How can I manage this?

g=sns.relplot(x="TimeStamp", y="DP Inlet", hue="humidity", data=df).set(title='DP inlet over time vs Temp')

sns.set(font_scale = 1)

g.fig.set_figwidth(30.27)
g.fig.set_figheight(20.7)

Output graph:

enter image description here

DavidG
  • 24,279
  • 14
  • 89
  • 82

1 Answers1

1

Since data is not provided to reproduce the image, I am using dataset provided within Seaborn to help with this:

import matplotlib.pyplot as plt 
import seaborn as sns 

tips = sns.load_dataset("tips")
g = sns.relplot(data=tips, x="total_bill", y="tip", hue="day")

def specs(x, **kwargs):
    plt.axhline(x.mean(), c='k', ls='-', lw=2.5)

g.map(specs, 'tip')
plt.show()

This gives:

enter image description here

For more detailed solution, please check How to add a mean and median line to a Seaborn displot. I have used this answer from the same post for adding mean line to the plot.

medium-dimensional
  • 1,974
  • 10
  • 19