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
23
votes
1 answer

Clustered bar plot in gnuplot

I have a simple result table which I want to plot as a clustered histogram plot in gnuplot. The data set has the category of content type of a webpage and the corresponding percentage share in two columns. I have this for two browsers. For…
sfactor
  • 12,592
  • 32
  • 102
  • 152
23
votes
5 answers

How to align the bars of a histogram with the x axis?

Consider this simple example library(ggplot2) dat <- data.frame(number = c(5, 10, 11 ,12,12,12,13,15,15)) ggplot(dat, aes(x = number)) + geom_histogram() See how the bars are weirdly aligned with the x axis? Why is the first bar on the left of 5.0…
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
23
votes
3 answers

how to change the order of factor plot in seaborn

My data looks like this: m=pd.DataFrame({'model':['1','1','2','2','13','13'],'rate':randn(6)},index=['0', '0','1','1','2','2']) I want to have the x-axis of factor plot ordered in [1,2,13] but the default is [1,13,2]. Does anyone know how to…
MYjx
  • 4,157
  • 9
  • 38
  • 53
23
votes
2 answers

R: How can I make a barplot with labels parallel (horizontal) to bars

In barplot, is it possible to make the labels parallel to the bars? Suppose we have the data frame called "data". Page PV UniquePgv 1 /photos/upcoming 5295 2733 2 / 4821 2996 3 /search 1201 …
CompChemist
  • 903
  • 2
  • 8
  • 15
23
votes
4 answers

position legend of a stacked bar plot

I am trying to create a stacked bar plot, but I cannot position the legend so that it does not overlap any of the bars. I have tried adjusting the margins, setting xlim, using a separate legend statement and searching here, all without success. …
Mark Miller
  • 12,483
  • 23
  • 78
  • 132
23
votes
2 answers

Automatically setting y-axis limits for bar graph using matplotlib

Here's an example of graphing large values. import matplotlib.pyplot as plt x = [1,2,3,4,5] y = [1000, 1002, 1001, 1003, 1005] plt.bar(x,y) plt.show() The y-axis starts at 0, so the bars all look equal. I know you can use plt.ylim to manually set…
user1473483
  • 305
  • 1
  • 3
  • 7
22
votes
2 answers

How to set the hue order in Seaborn plots

I have a Pandas dataset named titanic I am plotting a bar chart as described in the Seaborn official documentation, using the following code: import seaborn as sns titanic = sns.load_dataset("titanic") sns.catplot(x="sex", y="survived",…
Marioanzas
  • 1,663
  • 2
  • 10
  • 33
22
votes
2 answers

matplotlib bar plot add legend from categories dataframe column

I try to add the legend which should, according to my example, output: a red square with the word fruit and a green square with the word veggie. I tried several things (the example below is just 1 of the many trials), but I can't get it work.…
S12000
  • 3,345
  • 12
  • 35
  • 51
22
votes
4 answers

Remove Seaborn barplot legend title

I use seaborn to plot a grouped bar plot as in https://seaborn.pydata.org/examples/factorplot_bars.html Giving me: https://seaborn.pydata.org/_images/factorplot_bars.png there is a title (sex) on the legend which I would like to remove. How could I…
hangc
  • 4,730
  • 10
  • 33
  • 66
22
votes
2 answers

ggplot2 3D Bar Plot

I Know this sounds basic, but have a been searching for literally more than an hour now without success. I'm simply trying to plot a 3D bar plot in 'R' using the 'ggplot2' package. My dataframe looks something like this: x y z t1 5 …
Tavi
  • 2,668
  • 11
  • 27
  • 41
22
votes
2 answers

Legends in barplot not appearing properly

heights1=c(5,5,4.5,4,4,4,4.5,2,4,4) opar <- par(lwd = 0.3) barplot(heights1,xlim=c(0,3), ylim=c(0,5), width=0.1, main="Langauges(Verbal & Non-verbal)", names.arg=c("Spanish", "Speak" , "English","Speak", "Hindi", "Speak", "Arabic", "Speak", …
gpuguy
  • 4,607
  • 17
  • 67
  • 125
21
votes
2 answers

draw the sum value above the stacked bar in ggplot2

How do I draw the sum value of each class (in my case: a=450, b=150, c=290, d=90) above the stacked bar in ggplot2? Here is my…
swchen
  • 643
  • 2
  • 8
  • 24
21
votes
3 answers

Horizontal stacked bar plot and add labels to each section

I am trying to replicate the following image in matplotlib and it seems barh is my only option. Though it appears that you can't stack barh graphs so I don't know what to do If you know of a better python library to draw this kind of thing, please…
Griff
  • 2,064
  • 5
  • 31
  • 47
21
votes
1 answer

Plotting bar charts on map using ggplot2?

I would like to produce a barplot for each location on a map using ggplot2, as was done by xingmowang with base graphics and a number of packages: http://nzprimarysectortrade.wordpress.com/2011/10/02/let-r-fly-visualizing-export-data-using-r/ This…
Etienne Low-Décarie
  • 13,063
  • 17
  • 65
  • 87
21
votes
4 answers

Indicating the statistically significant difference in bar graph

I use a bar graph to indicate the data of each group. Some of these bars differ significantly from each other. How can I indicate the significant difference in the bar plot? import numpy as np import matplotlib.pyplot as plt menMeans = (5, 15, 30,…
imsc
  • 7,492
  • 7
  • 47
  • 69