A grouped bar chart (aka clustered bar chart, multi-series bar chart) plots numeric values for two levels of categorical variables instead of one. Bars are grouped by position for levels of one categorical variable, with color indicating the secondary category level within each group.
Questions tagged [grouped-bar-chart]
138 questions
154
votes
8 answers
How to plot multiple bars grouped
How to plot multiple bars in matplotlib, when I tried to call the bar function multiple times, they overlap and as seen the below figure the highest value red can be seen only.
How can I plot the multiple bars with dates on the x-axes?
So far, I…

John Smith
- 2,668
- 7
- 30
- 34
86
votes
10 answers
How to have clusters of stacked bars
So here is how my data set looks like :
In [1]: df1=pd.DataFrame(np.random.rand(4,2),index=["A","B","C","D"],columns=["I","J"])
In [2]: df2=pd.DataFrame(np.random.rand(4,2),index=["A","B","C","D"],columns=["I","J"])
In [3]: df1
Out[3]:
…

jrjc
- 21,103
- 9
- 64
- 78
81
votes
2 answers
Plot multiple columns of pandas DataFrame on the bar chart
I am using the following code to plot a bar-chart:
import matplotlib.pyplot as pls
my_df.plot(x='my_timestampe', y='col_A', kind='bar')
plt.show()
The plot works fine. However, I want to improve the graph by having 3 columns: 'col_A', 'col_B',…

Edamame
- 23,718
- 73
- 186
- 320
66
votes
4 answers
Bar-Plot with two bars and two y-axis
I have a DataFrame looking like this:
amount price
age
A 40929 4066443
B 93904 9611272
C 188349 19360005
D 248438 24335536
E 205622 18888604
F 140173 12580900
G 76243 6751731
H 36859 3418329
I …

tim
- 9,896
- 20
- 81
- 137
52
votes
1 answer
Change bar color according to hue name
I'm using seaborn and pandas to create some bar plots from different (but related) data. The two datasets share a common category used as a hue, and as such I would like to ensure that in the two graphs the bar color for this category matches. How…

asongtoruin
- 9,794
- 3
- 36
- 47
52
votes
6 answers
How to add percentages on top of grouped bars
Given the following count plot how do I place percentages on top of the bars?
import seaborn as sns
sns.set(style="darkgrid")
titanic = sns.load_dataset("titanic")
ax = sns.countplot(x="class", hue="who", data=titanic)
For example for "First" I…

collarblind
- 4,549
- 13
- 31
- 49
33
votes
4 answers
How to create a grouped bar plot
The goal here is to create a grouped bar plot, not subplots like the image below
Is there a simple way to create a grouped bar plot in Python? Right now I get separate bar plots, instead of separate bars on one plot.
import pandas as pd
df =…

Rilcon42
- 9,584
- 18
- 83
- 167
29
votes
2 answers
Grouped Bar graph Pandas
I have a table in a pandas DataFrame named df:
+--- -----+------------+-------------+----------+------------+-----------+
|avg_views| avg_orders | max_views |max_orders| min_views |min_orders…

Shubham R
- 7,382
- 18
- 53
- 119
20
votes
3 answers
Setting spacing between grouped bar plots
I'm trying to make a grouped bar plot in matplotlib, following the example in the gallery. I use the following:
import matplotlib.pyplot as plt
plt.figure(figsize=(7,7), dpi=300)
xticks = [0.1, 1.1]
groups = [[1.04, 0.96],
[1.69,…
user248237
12
votes
1 answer
Pandas Dataframe to Seaborn Grouped Barchart
I have the following dataframe which I have obtained from a larger dataframe which lists the worst 10 "Benchmark Returns" and their corresponding portfolio returns and dates:
I've managed to create a Seaborn bar plot which lists Benchmark Returns…

Vladimir Nabokov
- 265
- 1
- 2
- 7
12
votes
2 answers
ggplot multiple grouping bar
I would like to know how to get 9 grouping bar plot (3x3) together.
My CSV:
data <- read.csv("http://pastebin.com/raw.php?i=6pArn8GL", sep = ";")
The 9 plots should be grouped according "Type" A to I.
Then each grouped bar plot should have the…

S12000
- 3,345
- 12
- 35
- 51
7
votes
1 answer
Using seaborn barplot to plot wide-form dataframes
I'm trying to produce a bar chart with all the observations in my DataFrame, which looks like this:
import pandas as pd
data = {0: [52, 52, 52, 45, 0, 0],
1: [49, 52, 52, 0, 0, 0],
2: [48, 52, 52, 41, 0, 0]}
# (rows = years,…

Silviu Tofan
- 379
- 1
- 3
- 17
6
votes
4 answers
Making a clustered bar chart
I have a little pandas dataframe that looks like this:
import pandas as pd
data = {'Word': ['drink', 'cherry', 'berry', 'plum', 'crisp', 'spices'],
'Percentage1': [18.166654, 13.498262, 9.810123, 7.964429, 7.892941, 0.856775],
…

Olga
- 75
- 1
- 1
- 5
6
votes
1 answer
Grouped seaborn.barplot from a wide pandas.DataFrame
I have pandas dataframe, one index(datetime) and three variables(int)
date A B C
2017-09-05 25 261 31
2017-09-06 261 1519 151
2017-09-07 188 1545 144
2017-09-08 200 2110 232
2017-09-09 292 2391 325
I can create…

jayko03
- 2,329
- 7
- 28
- 51
6
votes
2 answers
How to draw a bar plot with two categories and four series
I have the following dataframe, where pd.concat has been used to group the columns:
a b
C1 C2 C3 C4 C5 C6 C7 C8
0 15 37 17 10 8 11 19 86
1 39 84 11 5 5 13 9 11
2 10 20 30 51 74 62 56…

FaCoffee
- 7,609
- 28
- 99
- 174