I am trying to put the title of the legend on top, whereas the values are distributed horizontally but I cannot. Any hints will be very appreciated.
The code below provides the graph below, but I don't have space on my graph so I need something like this:
Sex
Female Male
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))
lp1 <- ggplot(data=df1,
aes(x=time, y=total_bill, group=sex, shape=sex, colour=sex)) +
geom_line() +
geom_point() +
theme_bw() +
theme(
legend.direction = "horizontal",
) +
scale_color_manual(values=c("#0000CC", "#CC0000"),
name = 'Gender')
lp1

