ggplot2 error “no layers in plot”

前端 未结 2 761

I have seen the question already asked... and solved adding stat = \"identity\" to geom_bar. But in my case, this does not solve anything (I still

相关标签:
2条回答
  • 2020-12-15 19:30

    the error was because the geom_line() or geom_point() option was not added. You can directly plot it without saving it as object on adding this option.

    0 讨论(0)
  • 2020-12-15 19:44

    The error message is due to fact that you didn't save d+geom_line() as an object.

    #Save ggplot() as object
    d <- ggplot(data=data3, aes(x=MonthNB, y=Ptot, colour=StationNAME))
    
    #Add to d geom_line() - this makes the plot to appear on the screen but not saved.
    d + geom_line()
    

    To save layer to object

    d<-d+geom_line()
    #No error message
    d
    
    0 讨论(0)
提交回复
热议问题