Skip to content

Instantly share code, notes, and snippets.

@lejon
Created August 6, 2018 11:36
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/adcab043481c72f9e2d22621eb85bcd1 to your computer and use it in GitHub Desktop.
Save lejon/adcab043481c72f9e2d22621eb85bcd1 to your computer and use it in GitHub Desktop.
Ggplot histogram object from vector of counts
library(ggplot2)
plot_hist <- function(counts, title = "Histogram") {
fdf <- as.data.frame(table(counts))
pl <- (ggplot(fdf,aes(x=counts,y=Freq,ymin=0,ymax=Freq))
+ 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