Seaborn lineplot using median instead of mean

Forever picture Forever · Sep 26, 2018 · Viewed 7.2k times · Source

I'm using seaborn.lineplot() to create a line figure like this (a line representing mean, surrounded by a band representing the std):

sns.lineplot(x="trial", y="rvalues", hue="subject", err_style="band", ci='sd', data=df)

enter image description here

My only issue is that since my data is not Gaussian, I care more about the median instead of mean. How to do that in Seaborn?

Or are there similar tools that are capable? I know I can do from scratch in matplotlib but that requires a lot of work to make it this nice.

Answer

Chang Ye picture Chang Ye · Dec 6, 2018

estimator should be a pandas method.

Use estimator=np.median instead of estimator="median".

sns.lineplot(x="trial", y="rvalues", hue="subject", err_style="band",
             ci='sd',
             estimator=np.median,
             data=df)