【问题标题】:ggplot why 'show.legend = FALSE' not working? [duplicate]ggplot 为什么'show.legend = FALSE'不起作用? [复制]
【发布时间】:2020-12-18 09:41:10
【问题描述】:

我的闪亮应用中有这段代码, 有人能告诉我为什么show.legend = FALSE 不工作吗? 我想删除图例。

这是我的项目http://webcovid19.online/ 图例不起作用,例如这里http://webcovid19.online/?country=Slovakia

output$dead_inc_country_bar_plot <- renderPlotly({
     ggplotly(
       
       
       ggplot(filtered_dead_inc_country_bar_data(), aes(x = date, y = deaths, color = country,group = country, text=paste(date, "\n" , country, " " ,deaths  ))) +
         geom_bar(stat='identity',fill='red', show.legend = FALSE)  +
         scale_x_date(limits = as.Date(c(ymd(date_last)-30,ymd(date_last)+1))) +
         scale_y_continuous(labels = comma, limits = c(0, NA)),
       tooltip = "text"
       
     ) %>%
       style (hoverlabel = list(font=list(size=20)))
     
     
   }
   )  

【问题讨论】:

    标签: r ggplot2 shiny


    【解决方案1】:

    试试:

    g1 <- ggplotly(ggplot(...) +
       geom_bar(...))
    
    hide_legend(g1)
    
    

    【讨论】:

      【解决方案2】:

      谢谢大家,我刚刚解决了theme(legend.position = "none") 的问题

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-06-05
        • 2016-11-18
        • 2016-01-24
        • 2013-03-05
        • 2012-10-01
        • 2014-07-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多