Skip to content

Instantly share code, notes, and snippets.

View AMacumber's full-sized avatar
👔
Employed as a Data Analyst at National Association of Friendship Centres

Andrew L Macumber AMacumber

👔
Employed as a Data Analyst at National Association of Friendship Centres
View GitHub Profile
@AMacumber
AMacumber / matplotlib_barplot.md
Last active May 29, 2019 14:46 — forked from ctokheim/matplotlib_barplot.md
Matplotlib: Stacked and Grouped Bar Plot

Stacked and Grouped Bar Plot

Oddly enough ggplot2 has no support for a stacked and grouped (position="dodge") bar plot. The seaborn python package, although excellent, also does not provide an alternative. However, I knew it was surely possible to make such a plot in regular matplotlib. Matplotlib, although sometimes clunky, gives you enough flexibility to precisely place plotting elements which is needed for a stacked and grouped bar plot.

Below is a working example of making a stacked and grouped bar plot.

import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np