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
78
votes
3 answers

Order categories by count in a seaborn countplot

I know that seaborn.countplot has the attribute order which can be set to determine the order of the categories. But what I would like to do is have the categories be in order of descending count. I know that I can accomplish this by computing the…
Econ
  • 1,075
  • 1
  • 8
  • 13
78
votes
6 answers

Bar plot, no space between bottom of geom and x axis keep space above

When I plot a bar graph in ggplot2 I would like to reduce the space between the bottom of the bars and the x-axis to 0, yet keep the space above the bars and the plot box. I have a hack to do it below. It's dirty and I want to be clean again. Is…
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
68
votes
4 answers

How to prevent overlapping x-axis labels in sns.countplot

For the plot sns.countplot(x="HostRamSize",data=df) I got the following graph with x-axis label mixing together, how do I avoid this? Should I change the size of the graph to solve this problem?
william007
  • 17,375
  • 25
  • 118
  • 194
59
votes
4 answers

How to prevent x-axis labels from overlapping

I'm generating a bar-chart with matplotlib. It all works well but I can't figure out how to prevent the labels of the x-axis from overlapping each other. Here an example: Here is some sample SQL for a postgres 9.1 database: drop table if exists…
zehpunktbarron
  • 1,193
  • 3
  • 15
  • 26
58
votes
4 answers

How to plot bar graphs with same X coordinates side by side ('dodged')

import matplotlib.pyplot as plt gridnumber = range(1,4) b1 = plt.bar(gridnumber, [0.2, 0.3, 0.1], width=0.4, label="Bar 1", align="center") b2 = plt.bar(gridnumber, [0.3, 0.2, 0.2], color="red", width=0.4, …
Bruce
  • 33,927
  • 76
  • 174
  • 262
57
votes
2 answers

Grouped bar plot in ggplot

I have a survey file in which row are observation and column question. Here are some fake data they look like: People,Food,Music,People P1,Very Bad,Bad,Good P2,Good,Good,Very Bad P3,Good,Bad,Good P4,Good,Very Bad,Very Good P5,Bad,Good,Very…
S12000
  • 3,345
  • 12
  • 35
  • 51
57
votes
6 answers

Put stars on ggplot barplots and boxplots - to indicate the level of significance (p-value)

It's common to put stars on barplots or boxplots to show the level of significance (p-value) of one or between two groups, below are several examples: The number of stars are defined by p-value, for example one can put 3 stars for p-value < 0.001,…
Ali
  • 9,440
  • 12
  • 62
  • 92
56
votes
2 answers

Reverse stacked bar order

I'm creating a stacked bar chart using ggplot like this: plot_df <- df[!is.na(df$levels), ] ggplot(plot_df, aes(group)) + geom_bar(aes(fill = levels), position = "fill") Which gives me something like this: How do I reverse the order the stacked…
Simon
  • 9,762
  • 15
  • 62
  • 119
55
votes
4 answers

Edit the width of bars using pd.DataFrame.plot()

I am making a stacked bar plot using: DataFrame.plot(kind='bar',stacked=True) I want to control width of bars so that the bars are connected to each other like a histogram. I've looked through the documentation but to no avail - any suggestions? Is…
Osmond Bishop
  • 7,560
  • 14
  • 42
  • 51
54
votes
4 answers

how to hide highchart x - axis data values

I am drawing a bar chart using highchart.js I do not want to show the x - axis data values. Can any one tell me which option does it? full config: var chart = new Highcharts.Chart({ chart: { renderTo: container, …
Nurul Asad
  • 541
  • 1
  • 4
  • 4
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
51
votes
2 answers

Ordering of bars in ggplot

I have looked through the answers in this forum but cannot seem to find an answer to this specific problem. I have the following data and want to create a bar chart where the bars are ordered from largest to smallest in terms of "Value", rather than…
Gregory Saxton
  • 1,241
  • 4
  • 13
  • 29
51
votes
4 answers

How to increase the space between bar plot bars

How do I increase the space between each bar with matplotlib barcharts, as they keep cramming them self to the centre. (this is what it currently looks) import matplotlib.pyplot as plt import matplotlib.dates as mdates def ww(self):#wrongwords text…
Smith
  • 631
  • 1
  • 5
  • 11
51
votes
7 answers

Multirow axis labels with nested grouping variables

I would like the levels of two different nested grouping variables to appear on separate lines below the plot, and not in the legend. What I have right now is this code: data <- read.table(text = "Group Category Value S1 A 73 S2 A 57 …
pawels
  • 1,070
  • 1
  • 10
  • 16
50
votes
3 answers

plotting value_counts() in seaborn barplot

I'm having trouble getting a barplot in seaborn. Here's my reproducible data: people = ['Hannah', 'Bethany', 'Kris', 'Alex', 'Earl', 'Lori'] reputation = ['awesome', 'cool', 'brilliant', 'meh', 'awesome', 'cool'] dictionary = dict(zip(people,…
AZhao
  • 13,617
  • 7
  • 31
  • 54