1

I would like to change the size and the position of the legend for the vertical lines in my plot. Here is the code:

central_values <- data.frame(measurement = c("mean", "median"),
                             value = c(mean(CBGrecord_days[,2]), median(CBGrecord_days[,2])))

ggplot(CBGrecord_days, aes(x=CBGrecord_days[,2])) + 
  geom_histogram(color="darkblue", fill="lightblue", binwidth=17)+
    xlab("Number of days recorded")+ # for the x axis label
      ylab("Number of individuals")+
        scale_y_continuous(breaks=c(seq(0,40,5)))+
          scale_x_continuous(breaks=c(seq(0,230,15)))+
            geom_vline(data = central_values, aes(xintercept = value, color = measurement),size=1.2)+
               scale_color_manual(values = c("red", "darkblue"), name = NULL) +
              theme(panel.background = element_rect(fill = "white", colour = "grey50"),
                axis.text=element_text(size=32),
                  axis.title=element_text(size=40))+guides(color = guide_legend(title=NULL))

Thank you!

camille
  • 16,432
  • 18
  • 38
  • 60
user11849
  • 39
  • 2
  • 3
    [See here](https://stackoverflow.com/q/5963269/5325862) on making a reproducible example that is easier for folks to help with. Without any data, we can't run your code, and you haven't included any output, so it's unclear what you're working with, what you're trying to change, and how you're trying to change it – camille Mar 11 '21 at 22:36

0 Answers0