I didn't use r
but I have recently decided to use it to plot graphs because of its great capability to do so. 'd like to plot a graph that shows voter turnout in elections. I know little about proper (i.e. correct in regard of their look) graphs so I found in the Internet one that looks (to me) fine. Here's this graph:
Here's my graph. You can see that it is far from being good (screenshot is from R-Fiddle and I think the graph may look different when compiled from desktop R).
What should I do to make it better (e.g. readible)? Specifically, do I need titles for x and y axis? Does it look better if the values are on top of bars (like in my graph) or within bar (the graph found in the Internet)?
My code is:
# Load packages
library(ggplot2)
library(scales)
# Create dataset
dat <- data.frame(years = c("1991", "1993", "1997", "2001", "2005", "2007", "2011", "2015"),
freq = c(43.20, 52.13, 47.93, 46.29, 40.57, 53.88, 48.92, 50.92))
# Create graph bar
ggplot(dat, aes(years, freq)) + geom_bar(stat = "identity", width=0.55)
+ geom_text(aes(label=comma(freq), y=freq+1.1))
+ scale_y_continuous(breaks = seq(0,50,10)) + theme_classic()
EDIT:
I tried to incorporate as many suggestions in comments and answers as I could. I've come up with the following:
What do you think of it?
ggplot(dat, aes(years, freq)) + geom_bar(stat = "identity", width=0.55, fill="grey")+ scale_y_continuous(breaks = seq(0,50,10)) + geom_hline(yintercept= seq(0,50,10), col="white") + theme_classic(base_size = 16) + labs(x=NULL, y=NULL) + ggtitle("freq per year")
. $\endgroup$ggplot(dat, aes(years, freq)) + geom_bar(stat = "identity", width=0.55, fill="grey64")+ scale_y_continuous(breaks = seq(0,65,10)) + geom_hline(yintercept= seq(0,65,10), col="white") + theme_classic(base_size = 16) + labs(x=NULL, y=NULL) + geom_text(aes(label=format(freq,decimal.mark = ","), y=freq+2.2), size=3)
. Let me know what you think about it. To me your answer deserves to be given as an answer. $\endgroup$