R GGPLOT-多个图例的顺序(geom_线和geom_线加geom_点)

R GGPLOT-多个图例的顺序(geom_线和geom_线加geom_点),r,ggplot2,graph,graphics,R,Ggplot2,Graph,Graphics,我搜索了很多已经回答过的问题,但没有一个能帮到我 这是我的代码: ggplot(z, aes(x=`Fecha de muestreo`, y = Valor, color = `Nombre de la estación`)) + geom_line(size = 0.4) + geom_point(size=0.5) + scale_x_date(date_labels = "%b", breaks = "1 month", limi

我搜索了很多已经回答过的问题,但没有一个能帮到我

这是我的代码:

ggplot(z, aes(x=`Fecha de muestreo`, y = Valor, color = `Nombre de la estación`)) + 
  geom_line(size = 0.4) + 
  geom_point(size=0.5) + 
  scale_x_date(date_labels = "%b", breaks = "1 month", limits = c(as.Date("2019-1-1"), as.Date("2019-12-20"))) + 
  scale_y_continuous("pH (unidades de pH)", limits = c(3, 11), breaks = c(3:11)) +
  geom_hline(aes(yintercept = 6.5, linetype = "ECA cat.3 inf D1 y D2 : 6.5"), colour = "Blue", size = 0.4)+
  geom_hline(aes(yintercept = 8.4, linetype = "ECA cat.3 sup. D1 : 8.4"), colour = "Green", size = 0.4)+
  geom_hline(aes(yintercept = 8.5, linetype = "ECA cat.3 sup. D2 : 8.5"), colour = "red", size = 0.4)+
  scale_linetype_manual(name = NULL, values = c(1, 1, 1), # values = tipo de lineas
                        guide = guide_legend(override.aes = list(color = c("blue", "Green", "Red")))) +
  theme(axis.text=element_text(size=6), 
        legend.margin = unit(-0.2, "cm"),
        axis.title=element_text(size=7,face="bold")) +
  theme(legend.text=element_text(size=6), 
        legend.title = element_blank(), 
        legend.spacing.x = unit(.2, 'cm')) + 
  theme(legend.key = element_rect(fill = "white")) +
  theme(panel.background = element_rect(fill = "white")) +
  theme(panel.grid = element_line(colour= "gray"))
这是图表:

我需要更改图例的顺序:ECA应该在底部。
我该怎么做呢?

这应该可以使用指南的订购条款。例如:

library(ggplot2)
a <- ggplot(mtcars, aes(wt, mpg, 
                   color = as.character(cyl), 
                   fill = as.character(gear))) +
  geom_point(size = 5, shape = 21, stroke = 2) +
  scale_color_discrete(name = "cyl as color") +
  scale_fill_discrete(name = "gear as fill")
a  
这能解决你的问题吗?
a +
  guides(color = guide_legend(order = 0),
         fill  = guide_legend(order = 1))