how to overlap two barplots in seaborn

Solutions on MaxInterview for how to overlap two barplots in seaborn by the best coders in the world

showing results for - "how to overlap two barplots in seaborn"
Olivia
01 Apr 2017
1# instead of seaborn use plt.bar 
2
3import matplotlib.pyplot as plt
4import seaborn as sns
5
6# Load the example car crash dataset
7crashes = sns.load_dataset("car_crashes").sort_values("total", ascending=False)
8
9# states of interest
10txcahi = crashes[crashes['abbrev'].isin(['TX','CA','HI'])]
11
12# Plot the total crashes
13f, ax = plt.subplots(figsize=(10, 5))
14plt.xticks(rotation=90, fontsize=10)
15
16plt.bar(height="total", x="abbrev", data=crashes, label="Total", color="lightgray")
17plt.bar(height="total", x="abbrev", data=txcahi, label="Total", color="red")
18
19sns.despine(left=True, bottom=True)