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
251
votes
5 answers

Label axes on Seaborn Barplot

I'm trying to use my own labels for a Seaborn barplot with the following code: import pandas as pd import seaborn as sns fake = pd.DataFrame({'cat': ['red', 'green', 'blue'], 'val': [1, 2, 3]}) fig = sns.barplot(x = 'val', y = 'cat', …
Erin Shellman
  • 3,553
  • 4
  • 21
  • 26
225
votes
11 answers

How to display the value on horizontal bars

I generated a bar plot, how can I display the value of the bar on each bar? Current plot: What I am trying to get: My code: import os import numpy as np import matplotlib.pyplot as plt x = [u'INFO', u'CUISINE', u'TYPE_OF_PLACE', u'DRINK',…
Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501
169
votes
7 answers

How to add value labels on a bar chart

I'm creating a bar chart, and I can't figure out how to add value labels on the bars (in the center of the bar, or just above it). I believe the solution is either with 'text' or 'annotate', but I: a) don't know which one to use (and generally…
Optimesh
  • 2,667
  • 6
  • 22
  • 22
160
votes
4 answers

How can I change the Y-axis figures into percentages in a barplot?

How can we change y axis to percent like the figure? I can change y axis range but I can't make it to percent.
STAT
147
votes
4 answers

Showing data values on stacked bar chart in ggplot2

I'd like to show data values on stacked bar chart in ggplot2. Here is my attempted code library(ggplot2) Data <- data.frame( Year = c(rep(c("2006-07", "2007-08", "2008-09", "2009-10"), each = 4)), Category = c(rep(c("A", "B", "C", "D"), times =…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
132
votes
1 answer

Position geom_text on dodged barplot

I tried to make the title self-explanatory, but here goes - data first: dtf <- structure(list(variable = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L), .Label = c("vma", "vla", "ia", "fma", "fla"), class = "factor"), ustanova =…
aL3xa
  • 35,415
  • 18
  • 79
  • 112
127
votes
8 answers

Rotating x axis labels in R for barplot

I am trying to get the x axis labels to be rotated 45 degrees on a barplot with no luck. This is the code I have below: barplot(((data1[,1] - average)/average) * 100, srt = 45, adj = 1, xpd = TRUE, …
David
  • 2,834
  • 6
  • 26
  • 31
122
votes
2 answers

How to put labels over geom_bar for each bar in R with ggplot2

I've found this, How to put labels over geom_bar in R with ggplot2, but it just put labels(numbers) over only one bar. Here is, let's say, two bars for each x-axis, how to do the same thing? My data and code look like this: dat <- read.table(text…
Puriney
  • 2,417
  • 3
  • 20
  • 25
113
votes
5 answers

How do you plot bar charts in gnuplot?

How do you plot bar charts in gnuplot with text labels?
tatwright
  • 37,567
  • 6
  • 21
  • 9
113
votes
3 answers

Setting Different Bar color in matplotlib Python

Supposely, I have the bar chart as below: Any ideas on how to set different colors for each carrier? As for example, AK would be Red, GA would be Green, etc? I am using Pandas and matplotlib in Python >>> f=plt.figure() >>>…
Santiago Munez
  • 1,965
  • 5
  • 18
  • 16
99
votes
4 answers

R ggplot2: stat_count() must not be used with a y aesthetic error in Bar graph

I am getting this error while plotting a bar graph and I am not able to get rid of it, I have tried both qplot and ggplot but still the same error. Following is my code: library(dplyr) library(ggplot2) #Investigate data further to build a…
Uasthana
  • 1,645
  • 5
  • 16
  • 24
94
votes
3 answers

Pandas Plotting with Multi-Index

After performing a groupby.sum() on a DataFrame I'm having some trouble trying to create my intended plot. import pandas as pd import numpy as np np.random.seed(365) rows = 100 data = {'Month': np.random.choice(['2014-01', '2014-02', '2014-03',…
Reustonium
  • 2,575
  • 2
  • 16
  • 16
92
votes
4 answers

Barchart with vertical ytick labels

I'm using matplotlib to generate a (vertical) barchart. The problem is my labels are rather long. Is there any way to display them vertically, either in the bar or above it or below it?
phihag
  • 278,196
  • 72
  • 453
  • 469
90
votes
8 answers

How to display custom values on a bar plot

I'm looking to see how to do two things in Seaborn with using a bar chart to display values that are in the dataframe, but not in the graph. I'm looking to display the values of one field in a dataframe while graphing another. For example, below,…
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
1
2 3
99 100