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
6
votes
2 answers
How to plot a grouped bar chart with errors bar as shown in the figure?
I am trying to plot a grouped bar chart like the one in the figure below. I found the errorbar() function, but so far I cannot figure it out how to make it.
Here is my code.
Y = [0.9322225 0.86225 0.8973;
0.8953635 0.862868 0.8099605;
…

zkan
- 641
- 1
- 12
- 27
5
votes
1 answer
Seaborn barplot from lists instead of dataframes
I'm being trying to convert my plots to Seaborn and I'm having an issue with a multiple barplot that I have. The data is a list of lists, like so:
raw_data = [[47.66773437098896, 47.585408826566024, 45.426437828641106, 44.955787935926836],
…
user8200327
4
votes
1 answer
stacked and grouped barchart
I have this data set
import pandas as pd
import plotly.express as px
elements = pd.DataFrame(data={"Area": ["A", "A", "A", "B", "B", "C", "C", "C"], "Branch": ["a1", "f55", "j23", "j99", "ci2", "p21", "o2", "q35"], "Good": [68, 3, 31, 59, 99, 86,…

A.Rahman Mahmoud
- 328
- 1
- 3
- 17
4
votes
1 answer
Configuring the Title and Axes for an Altair Graph
I was recently learning how to use Altair to create graphs, and had some trouble customizing the title and axes. My code for the graph currently looks like:
chart = Chart(data).mark_bar().encode(
column='Cell Type',
x='Truth/Pred',
…

p_mo
- 67
- 2
- 10
4
votes
1 answer
Combining two stacked bar plots for a grouped stacked bar plot
So I found the following code online:
import matplotlib.pyplot as plt
import matplotlib
matplotlib.style.use('ggplot')
plotdata = pd.DataFrame({
"2018_m":[40, 12, 10, 26, 36],
"2019_m":[19, 8, 30, 21, 38],
"2020_m":[10, 10, 42, 17,…

user356
- 303
- 2
- 10
4
votes
2 answers
How to plot a grouped bar plot from two or more dataframes
I have multiple dataframes, and I want to plot them on the same figure in the Grouped Bar Chart view.
These are two very small dataframes that I would like to plot together in the same figure.
The dataframes are:
I want to plot a figure like this…

Gizelly
- 417
- 2
- 10
- 24
4
votes
1 answer
Making seaborn.barplot by group with asymmetrical custom error bars
I have a Pandas dataframe that has a couple of group columns like below.
gr1 grp2 variables lb m ub
A A1 V1 1.00 1.50 2.5
A A2 V2 1.50 2.50 3.5
B A1 V1 3.50 14.50 30.5 …

Black
- 4,483
- 8
- 38
- 55
3
votes
1 answer
In R, what is the best way to add the p-values from comparisons between groups to a grouped bar chart
Please, consider the following MWE.
EDIT: Thanks to the very good comments, it became clear that there were not enough data in my very simplified MWE to do the statistical comparisons between the groups. Due to this shortcoming, I've rewritten the…

jaggedjava
- 440
- 6
- 14
3
votes
0 answers
plotly graph objects persistent data labels when clicking the graph
I'm generating a graph:
import plotly.graph_objects as go
When I click on a data point I get the x,y data as shown, but as soon as I move the mouse pointer to a different data point then the other disappears.
I want to have both points appear on…

magicsword
- 1,179
- 3
- 16
- 26
3
votes
2 answers
How to convert grouped bar chart from vertical to horizontal
How can this vertical grouped bar chart be changed to a horizontal bar chart (grouped, and stacked)? I need help to alter the code such that the bars are displayed horizontally instead of vertically.
import matplotlib.pyplot as plt
import numpy as…

Svein
- 47
- 3
3
votes
1 answer
Python Grouped bar chart with multiple x-labels
I would like to plot a relatively simpler bar chart but struggling to plot using Matplotlib. Could I get some help please. I would like to prepare a chart as shown on this Bar Chart. A sample data is shown below for Tests 1, 2 and 3.
I have more…

AjB
- 61
- 5
3
votes
1 answer
How to specify the x coordinate on a grouped bar chart on plotly?
I made a bar chart with python plotly, and I want to put a marker on a particular bar, example non-smoking females.
Does anyone know how to specify this?
I took an example from the plotly documentation, if I try to put the marker it just takes the…

ChemaChiles
- 75
- 1
- 4
3
votes
1 answer
I am trying to do categorical analysis I want to convert count values to percentage and I am getting an error
My code is:
sns.countplot(x='marital', hue='loan', data=df, estimator=lambda x: sum(x==0)*100.0/len(x))
It gives the following error:
AttributeError Traceback (most recent call last)
in…

nigel yaso
- 33
- 4
3
votes
1 answer
using pandas.DataFrame.melt() with seaborn.barplot
So, I have some data in two columns in a Pandas DataFrame:
Actual Predicted
0 2.8 2.854729
1 2.2 3.081473
2 4.2 3.211041
3 2.9 2.951905
4 3.4 3.211041
5 3.3 2.838533
6 3.5 3.194845
7 3.1 3.000493
8 2.8 3.016689
9 2.8…

rocksNwaves
- 5,331
- 4
- 38
- 77
3
votes
2 answers
How can I group a stacked bar chart?
I'm trying to create a grouped, stacked bar chart.
Currently I have the following DataFrame:
>>> df
Value
Rating 1 2 3
Context Parameter …

jogo
- 134
- 1
- 9