I want to move the title of the sex legend a little to the right to the horizontal center of the legend window. I tried theme and guide_legend but could not. Both methods will not change the position of the name of the legend.
# example data from http://www.cookbook-r.com/Graphs/Legends_(ggplot2)/ df1 <- data.frame( sex = factor(c("Female","Female","Male","Male")), time = factor(c("Lunch","Dinner","Lunch","Dinner"), levels=c("Lunch","Dinner")), total_bill = c(13.53, 16.81, 16.24, 17.42) ) library(ggplot2) p <- ggplot(data=df1, aes(x=time, y=total_bill, group=sex, shape=sex, colour=sex)) + geom_line() + geom_point()
In addition, I am using ggplot2_2.2.0.
r ggplot2 legend
mt1022
source share