Skip to content

Instantly share code, notes, and snippets.

@steveharoz
Created April 16, 2017 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steveharoz/5edcd68ac86e2989ef25e2e1346f8aff to your computer and use it in GitHub Desktop.
Save steveharoz/5edcd68ac86e2989ef25e2e1346f8aff to your computer and use it in GitHub Desktop.
grouped bars example
library(tidyverse)
# make some data
df = expand.grid(
x = 1:5,
category = LETTERS[1:3]
)
df$value = runif(nrow(df), 0, 50)
# chart
ggplot(df) +
aes(x=x, y=value, fill=category) +
geom_col(
width=0.7, # shrink the bars
position=position_dodge(width=0.7) # position the bars
)
@steveharoz
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment