简体   繁体   中英

ggplot : Hide geom_ribbon by default to my plot

I have this plot :

g.mean <- ggplot(df,aes(x = as.numeric(xx),y=yy,color=varc)) + 
      geom_line() +
      geom_ribbon(aes(ymin=Born_Inf, ymax=Born_Sup, fill=varc), alpha=0.1)

Is there a way to hide only geom_ribbon() and print geom_line() to my graph ? I try with "legendonly" but this hide all lines ...

style(ggplotly(g.mean, tooltip = c("varc")), hoverinfo = "value",visible="legendonly")  #,traces = 1

Hide geom_ribbon() with argument " traces " in function " style() ". For example : I have 10 factors in my varC so I have 10 lines (geom_line()) and 10 CI (geom_ribbon) : 20 items.

To hide geom_ribbon() indicates to " traces " 11:20 and visible="legendonly" .

style(ggplotly(g.mean, tooltip = c("varC","x","y")),
  visible="legendonly",
  hoverinfo = "value",
  traces = c((length(unique(df$varC))+1):(length(unique(df$varC))*2)))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM