如何使用ggplot更改组图例顺序

时间:2019-06-23 07:36:13

标签: r ggplot2

我画了一条线图。该图有3组。我想更改图例组的顺序。这是我的剧本

dummy_plot = ggplot(data = dataplot , aes(x = factor(indexsampling),group = method)) +
geom_line(aes( y = value,linetype = method,color=method),size=1)+
geom_point(aes( y = value,shape=method,color=method))+

theme(plot.title = element_text(hjust = 0.5),
      text = element_text(size=20),
      axis.text=element_text(size=18),
      legend.text=element_text(size=18),
      legend.title=element_blank(),
      legend.position = c(1, 0.5),
      legend.justification = c(1, 0),
      legend.background = element_rect(fill=alpha('white', 0.0))
)+
labs(title = title_name ,x = xlabel,y=ylabel,fill="")+
scale_linetype_manual(values=c("dotted", "twodash","solid"))+
scale_x_discrete( labels = c('0.625',"0.500","0.333","0.288"))+
scale_y_continuous(limits = c(0.2,0.62))

enter image description here

我想将标签更改为“ LC:Exp”,“ LC:Cubic”和“ Max”。 请建议我。

0 个答案:

没有答案