2

I plotted from data using seaborn's line plot whose code looks like this:

sns.lineplot( x=df["#Energy"], y=df["py"]+df["px"]+df["pz"])

and the plot I got is

enter image description here

now I want to color the area under it in opaque blue, how do I do that I dont find anything relevant to that in seaborn lineplot documentation All the efforts to help are appreciated

Sadaf Shafi
  • 1,016
  • 11
  • 27

1 Answers1

5

Seaborn doesn't seem to have such a function. However, you can use plt.fill_between:

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

df = pd.DataFrame([[0, 0], [1, 1], [2, 0]], columns=['x', 'y'])

fig, ax = plt.subplots()
sns.lineplot(x=df['x'], y=df['y'], ax=ax)
ax.fill_between(df['x'], df['y'], alpha=0.2)
plt.show()

It produces the following:

enter image description here

scandav
  • 749
  • 1
  • 7
  • 21