Skip to content

Instantly share code, notes, and snippets.

@lejon
Created March 7, 2019 21:47
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 lejon/62292df10b09f0f0ac568e4f1e1d26fd to your computer and use it in GitHub Desktop.
Save lejon/62292df10b09f0f0ac568e4f1e1d26fd to your computer and use it in GitHub Desktop.
Plot barchart in R
plot_bar <- function(vals, title = "Histogram") {
fdf <- as.data.frame(vals)
pl <- (ggplot(fdf,aes(x=1:nrow(fdf),y=vals,ymin=0,ymax=vals))
+ geom_bar(colour="white",fill="blue",stat="identity")
+ ggtitle(title)
+ theme(plot.title=element_text(family="Arial", size=10))
+ theme(axis.text.x = element_text(angle = 90, hjust = 1))
)
pl
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment