ggplot2无法显示图例

时间:2015-08-05 03:19:13

标签: r ggplot2

如何显示图例并为以下ggplot2设置主题?

ggplot2代码为:

   ggplot(data=df, environment=environment()) + ylab("YVAR") + xlab("XVAR") +
         #Actuals with dots
         geom_line( aes( x = Ratio, y = value), colour='#8EA5B7', size = 1.5) + 
         geom_point(aes(x=Ratio,y=value)) +

         #Line for the predictive model with dots
         geom_line(aes( x = Ratio, y = p), colour='#DC8772', size = 3) + 
         geom_point(aes(x=Ratio,y=p)) +

         #labels for the actual points
         geom_text(aes( x = Ratio, y = value, label = Total), size = 5) +

         # 3 standard devs max limit
         geom_line(aes( x = Ratio, y = sigma3 ), linetype = 'dashed' ) +

         # 3 standard devs min limit
         geom_line(aes( x = Ratio, y = sigma3m ), linetype = 'dashed') +

         # code for the formula
         geom_text(aes( x = 0.01, y = 0.5, label = my_label), colour="black", size=5, parse = TRUE) +

         #scale variable
         scale_colour_manual(values=c("Actual Readings", "Predictive Model")) + 

         # change background colour
         theme_bw()

我试图搞乱主题,但它没有用。 在图例中,我只想要geom_line的条目不是geom_textgeom_points的条目。

目前它看起来像这样:

current chart

0 个答案:

没有答案