Change The Barplot Bar Width

Want to learn more? I recommend working through: R for Data Science, R Cookbook, and R Graphics Cookbook.

# load the gcookbook package for the data
library(gcookbook)

# load the ggplot2 package
library(ggplot2)
# plot a default barplot
ggplot(pg_mean, aes(x=group, y=weight)) + geom_bar(stat="identity")

png

# plot a barplot with skinny bars
ggplot(pg_mean, aes(x=group, y=weight)) + geom_bar(stat="identity", width=0.5)

png

# plot a barplot with thick bars
ggplot(pg_mean, aes(x=group, y=weight)) + geom_bar(stat="identity", width=1)

png