GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • PYTHON CHARTS
  • matplotlib
  • seaborn
  • plotly
  • pandas
  • colors
  • COLORS
  • COLOR PALETTES
  • R CODER
  • R CHARTS
  • Contact
  • Español

This view

  • Original page
  • New address

GeezerVison is showing python-charts.com — Area chart in seaborn

Search for a graph

HOME EVOLUTION AREA PLOT SEABORN

Area chart in seaborn

Sample data

Consider the following data for illustration purposes:

import pandas as pd

# Data
df = pd.DataFrame({
    "month": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"],
    "revenue": [12, 15, 13, 18, 21, 19]})

Area chart in seaborn

Unlike matplotlib and plotly, seaborn does not have its own area-filling function: draw the line with lineplot and shade the area underneath with matplotlib’s fill_between on the same axes.

import seaborn as sns
import matplotlib.pyplot as plt

ax = sns.lineplot(x = "month", y = "revenue", data = df)
ax.fill_between(df["month"], df["revenue"], alpha = 0.3)

# plt.show()

Area chart in seaborn

Colors

Pass the same color to both lineplot and fill_between to keep the line and the fill consistent.

import seaborn as sns
import matplotlib.pyplot as plt

ax = sns.lineplot(x = "month", y = "revenue", data = df, color = "#C44E52")
ax.fill_between(df["month"], df["revenue"], color = "#C44E52", alpha = 0.3)

# plt.show()

Colors of an area chart in seaborn

Several groups

For several groups, plot each one’s line and fill separately, or let lineplot handle the hue grouping and loop only for the fills.

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

# Sample data
df2 = pd.DataFrame({
    "month": ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] * 2,
    "revenue": [12, 15, 13, 18, 21, 19, 8, 9, 11, 10, 14, 15],
    "region": ["North"] * 6 + ["South"] * 6})

ax = sns.lineplot(x = "month", y = "revenue", hue = "region", data = df2)
for region, group in df2.groupby("region"):
    ax.fill_between(group["month"], group["revenue"], alpha = 0.2)

# plt.show()

Area chart with several groups in seaborn

R CODER website
Better Data Visualizations

Better Data Visualizations

A Guide for Scholars, Researchers, and Wonks

Buy on Amazon
Data visualization

Data visualization

A practical introduction

Buy on Amazon

See also

Stacked area plot in matplotlib with stackplot

Stacked area plot in matplotlib with stackplot

Step plot in matplotlib

Step plot in matplotlib

Candlestick chart in Python with mplfinance

Candlestick chart in Python with mplfinance

Area plot in matplotlib with fill_between

Area plot in matplotlib with fill_between

Candlestick chart in plotly

Candlestick chart in plotly

Streamgraph in matplotlib

Streamgraph in matplotlib

Gantt chart in plotly

Gantt chart in plotly

Calendar heatmap in matplotlib with calplot

Calendar heatmap in matplotlib with calplot

Line plot in matplotlib

Line plot in matplotlib

Area chart in pandas

Area chart in pandas

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.