Questions tagged [bar-chart]

A bar chart is graphical representation of data where the value is represented by the length of the bar.

Bar charts are used for marking clear data which has discrete values. Some examples of discontinuous data include 'shoe size' or 'eye color', for which a bar chart is appropriate. In contrast, some examples of continuous data would be 'height' or 'weight'. A bar chart is very useful for recording certain information whether it is continuous or not continuous data. Bar charts also look a lot like histograms. They are often mistaken for each other.

Example of a bar chart, with 'Country' as the discrete data set.

enter image description here

Source: eNotes (Bar chart)

In scientific software for statistical computing and graphics, a bar-chart can be generated by function barplot.

8160 questions
49
votes
2 answers

How to add group labels for bar charts

I want to plot data of the following form, using matplotlib bar plot: data = {'Room A': {'Shelf 1': {'Milk': 10, 'Water': 20}, 'Shelf 2': {'Sugar': 5, 'Honey': 6} …
Varicus
  • 1,523
  • 2
  • 12
  • 12
47
votes
2 answers

matplotlib bar chart with dates

I know about plot_date() but is there a bar_date() out there? The general method would be to use set_xticks and set_xticklabels, but I'd like something that can handle time scales from a few hours out to a few years (this means involving the major…
Adam Greenhall
  • 4,818
  • 6
  • 30
  • 31
45
votes
2 answers

How to rotate X-axis labels in bokeh figure?

I'm just starting to use Bokeh. Below I create some args I use for the rect figure. x_length = var_results.index * 5.5 Multiplying the index by 5.5 gave me more room between labels. names = var_results.Feature.tolist() y_length =…
Liam Hanninen
  • 1,525
  • 2
  • 19
  • 37
43
votes
4 answers

How to display all x labels in R barplot?

This is a basic question but I am unable to find an answer. I am generating about 9 barplots within one panel and each barplot has about 12 bars. I am providing all the 12 labels in my input but R is naming only alternate bars. This is obviously due…
user2760
  • 2,273
  • 7
  • 25
  • 34
43
votes
4 answers

How to scale Seaborn's y-axis with a bar plot

I'm using factorplot(kind="bar"). How do I scale the y-axis, for example with log-scale? I tried tinkering with the plots' axes, but that always messed up the bar plot in one way or another, so please try your solution first to make sure it really…
user124114
  • 8,372
  • 11
  • 41
  • 63
41
votes
3 answers

ggplot2 : Plot mean with geom_bar

I have the following data frame: test2 <- data.frame(groups = c(rep("group1",4), rep("group2",4)), X2 = c(rnorm(4), rnorm(4)) , label = c(rep(1,2),rep(2,2),rep(1,2),rep(2,2))) and I am plotting the bar graphs for each label per group…
Cauchy
  • 1,677
  • 2
  • 21
  • 30
40
votes
3 answers

Matplotlib bar graph x axis won't plot string values

I am using Python 2.7 and matplotlib. I am attempting to reach into my database of ambulance calls and count up the number of calls that happen on each weekday. I will then use matplotlib to create a bar chart of this information to give the…
David Kulpanowski
  • 431
  • 1
  • 4
  • 6
40
votes
4 answers

How to remove gaps between bars in a bar chart

I'm making a bar chart in Matplotlib with a call like this: xs.bar(bar_lefts, bar_heights, facecolor='black', edgecolor='black') I get a barchart that looks like this: What I'd like is one with no white gap between consecutive bars, e.g. more like…
Bryce Thomas
  • 10,479
  • 26
  • 77
  • 126
40
votes
4 answers

Simplest way to do grouped barplot

I have the following dataframe: Catergory Reason Species 1 Decline Genuine 24 2 Improved Genuine 16 3 Improved Misclassified 85 4 Decline Misclassified 41 5 Decline Taxonomic 2 6 Improved …
Dizzy Bean
  • 411
  • 1
  • 4
  • 5
39
votes
4 answers

Matplotlib, horizontal bar chart (barh) is upside-down

TL'DR, the vertical bar charts are shown in a conventional way -- things line up from left to right. However, when it is converted to horizontal bar chart (from bar to barh), everything is upside-down. I.e., for a grouped bar chart, not only the…
xpt
  • 20,363
  • 37
  • 127
  • 216
37
votes
3 answers

How to get a barplot with several variables side by side grouped by a factor

I have a dataset which looks like this one below. I am trying to make a barplot with the grouping variable gender, with all the variables side by side on the x axis (grouped by gender as filler with different colors), and mean values of variables on…
roscoe1895
  • 539
  • 1
  • 5
  • 8
36
votes
2 answers

Bar plot with groupby

My categorical variable case_status takes on four unique values. I have data from 2014 to 2016. I would like to plot the distribution of case_status grouped by year. I try the following: df.groupby('year').case_status.value_counts().plot.barh() And…
jacob
  • 810
  • 3
  • 9
  • 19
33
votes
1 answer

How can I add hatches, stripes or another pattern or texture to a barplot in ggplot?

Suppose I have data with both an ordinal variable and a categorical variable: set.seed(35) df <- data.frame(Class = factor(rep(c(1,2),times = 80), labels = c("Math","Science")), StudyTime = factor(sort(sample(1:4, 16, prob =…
Ian Campbell
  • 23,484
  • 14
  • 36
  • 57
33
votes
2 answers

How to center stacked percent barchart labels

I am trying to plot nice stacked percent barchart using ggplot2. I've read some material and almost manage to plot, what I want. Also, I enclose the material, it might be useful in one place: How do I label a stacked bar chart in ggplot2 without…
AK47
  • 1,318
  • 4
  • 17
  • 30
33
votes
3 answers

Stacked Bar Plot in R

I've looked at the similar questions on here regarding stacked bar plots in R, but I'm still not having any luck. I have created the following data frame: A B C D E F G 1 480 780 431 295 670 360 190 2 720 350 377 255…
Evelyn
  • 451
  • 1
  • 4
  • 6