Questions tagged [geom-bar]

`geom_bar` is the geometric object description for creating a barplot in `ggplot2`

geom_bar is the geometric object description for creating a barplot in ggplot2, which is an actively maintained open-source chart-drawing library for R. is written by Hadley Wickham and based upon the principles of "Grammar of Graphics".

Resources for using geom_bar:

1029 questions
2
votes
2 answers

How to use geom_bar() to create two grouped columns in R

There has got to be an easy way to create one set of grouped bars for aware column and a another set of grouped bars for serious column with the individual bars within each group being the value for the respective regions. Final image should look…
2
votes
1 answer

ggplot: How can I put my legend information below the xaxis?

This is my data: data_g <- data.frame( study_ID = c("ben-amitay2006","ben-ari2018", "ben-ari2019a","ben-ari2019b","connolly2004","lopez2008","phelan2009","toren2007","ben-amitay2006","ben-ari2019b","connolly2004","ben-amitay2006", …
Anna
  • 21
  • 2
2
votes
2 answers

How to change the size of x-axis for categorical variables in ggplot2?

I am tryig to adjust the size of my x-axis in a plot so that it won't have too much blank space in the plot area. This is my plot: criterio.fig <- ggplot(criterio_sum, aes(x = session, y = mean, …
Juliana
  • 93
  • 1
  • 10
2
votes
2 answers

Display Counts on a ggplot

I want to display the total number of lengths per year on my graphs. How do I display the total number of lengths (FREQUENCY) per year on my graph? I do NOT want it displayed above each bar. I want the total number for that year. ggplot(data =…
Stacy
  • 25
  • 5
2
votes
1 answer

Percentage labels are not displayed over bar plot

I am trying to plot a barplot with percentage labels. However, the percentages are annoyingly not displayed above each respective bar, but is rather placed in the way you see below. Anyone know what is causing this and how to fix it? The code I used…
Illimar Rekand
  • 133
  • 1
  • 15
2
votes
1 answer

Reorder Overlaid Bars in Plot so Longer Bars are in back -R

I have a barplot that I want to overlay. The issue is that longer bars are covering shorter bars. There's a function in excel that allows for longer bars to be pushed to the back, and shorter bars brought to the forefront. How can I do that in R? My…
Yu Na
  • 112
  • 1
  • 18
2
votes
1 answer

R ggplot2: labels inside bars, no stacked geom_bar

I have the following dataset: data <- structure(list(Q14 = c("< 5 people", "> 11 people", "6-10 people", NA), count = c(148L, 13L, 34L, 21L), var = c("Team Size", "Team Size", "Team Size", "Team Size")), row.names = c(NA, -4L), class = c("tbl_df",…
Carrol
  • 1,225
  • 1
  • 16
  • 29
2
votes
1 answer

How to plot a barplot using ggplot

average Young 0.01921875 Cohoused Young 0.07111951 Old 0.06057224 Cohoused Old 0.12102273 I am using the above data frame to create a histogram or bar and my code is as follows: C…
LXJ
  • 43
  • 4
2
votes
1 answer

Add difference in % to a grouped bar chart

I have the following dataframe in r showing several attributes for some community districts (field CD) in two different years: #Example data with one single attribute x <- structure(list(numbldgs = c(195, 845, 3621, 3214, 10738, 793, 223, 957,…
2
votes
2 answers

Force geom_bar to not interfer with x ordering under any circumstances?

I am trying to disable the alphabetical reordering of the x variable in a geom_bar. I see lots of questions and answers around how to reorder the x variable in a simple bar chart (e.g. here, here, here), but each of the answers introduces complexity…
stevec
  • 41,291
  • 27
  • 223
  • 311
2
votes
1 answer

Problems with making scale_colour_manual work for my multi-factor bargraph on ggplot2 in R

I am trying to make a manual colour scale for my bar graph using plyr to summarize the data and ggplot2 to present the graph. The data has two variables: Region (displayed on the X-axis) Genotype (displayed by the fill) I have managed to do this…
Liptongal
  • 47
  • 5
2
votes
1 answer

How to vertically center labels with geom_bar (ggplot2)

I would be very grateful for some help with ggplot2. I cannot seem to be able to vertically center the labels on the bars. Here's the code: library(ggplot2) Group.id <- c(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3) Type.id <- c("a", "b", "c", "d", "a",…
iLib
  • 23
  • 4
2
votes
2 answers

R order geom_bar based on one level

How can I order the bar plot based on the first level of the variable var? Now the order is on the sum of the two bars I would like to have it ordered only by value where var is "first". Below a working example. library("ggplot2") ct <- rep(c("A",…
Jordan_b
  • 305
  • 1
  • 8
2
votes
1 answer

GGPlot combining/overlaying column and line (Gantt) charts

I would like to overlay rainfall data (column) over a Gantt chart that contains 'suggested sowing windows' and actual sowing dates. From the dataset, I can create both separately but not on one chart. Any pointers greatly appreciated. ## plot Gantt…
obs
  • 43
  • 7
2
votes
1 answer

R: Gaps between specific bars in ggplot

I have this bar graph. I generate the graph with this code: # Speedup Graph p <- ggplot(speedup_df, aes(x= benchmark, y = speedup, fill = factor(technique))) + geom_bar(stat = "identity", position = "dodge", width = 0.7) + …
vic
  • 359
  • 4
  • 18