8

I want to fill the area under a line plot so it looks as the picture below: it should look like it

instead of

enter image description here

built on the following .csv file:

01-01-97    1
01-02-97    2
01-03-97    3
     ...
01-11-17    251
01-12-17    252
01-01-18    253

what should I change in this code to generate the desired graph?

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

# load csv
df=pd.read_csv("test.csv")
# generate graph
g = sns.lineplot(x="Date", y="Data", data=df)

plt.show()
Stefan Smirnov
  • 695
  • 3
  • 6
  • 18

2 Answers2

13
plt.fill_between(df.Date.values, df.Data.values)
VanTan
  • 617
  • 4
  • 12
4

Here's an alternative, using a stacked line chart:

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

# load csv
df = pd.read_csv("test.csv")

# generate graph
plt.stackplot(df["Date"], df["Data"], alpha=0.5) 

plt.show()
Vishal
  • 377
  • 3
  • 10