【问题标题】:ggplotly toolbar position within shiny app闪亮的应用程序中的ggplotly工具栏位置
【发布时间】:2020-04-18 18:22:58
【问题描述】:

使用下面的代码,我可以创建我的 ggplotly 图。如下图所示,ggplotly 工具栏与绘图标题重叠。如何将工具栏移到绘图的左侧?

另外,如何在标题和图表之间添加空格?我尝试通过添加“br()”来做到这一点,但它不起作用?

我想知道是否有任何方法可以删除框中的“县”,使其仅显示县的名称(即,“艾伦县”出现在框中,而不是“县:艾伦县”)。

      linedataPlot_60 <- reactive ({


     line_60 <- ggplot(linedata_60(),
           aes(
             x = Year,
             y = Percentage,
            # colour = interaction (County.y, Age_Group),
             colour = County

           )) + geom_line(size = 1)+ #ylim(0,30)+
      geom_point(size = 1.5,
                 shape = 21,
                 fill = "white" ) +   #scale_colour_manual(values=cbbPalette) +
      theme_bw() + #scale_y_continuous(breaks=seq(0,40,1)) +
      theme(legend.title=element_blank(),legend.text = element_text(face = "bold"), plot.title = element_text(
        hjust = 0.5,
        size = 9,
        colour = "Black",
        face = "bold"
      ),axis.text=(blue.bold.10.text), axis.title=blue.bold.10.text)+
      ggtitle(paste(
        input$sex_,
        "Older Population (60 or over) in the Selected Counties",

      "\n",
        "(2010 to 2050)"
      ))
       ggplotly(line_60) 

  })

  output$line_60 <- renderPlotly ({
    linedataPlot_60()
  })

【问题讨论】:

  • 有什么想法吗?评论?

标签: r shiny ggplotly


【解决方案1】:

tooltip,请将aes修改为ggplot(linedata_60(),aes(x = Year,y = Percentage,colour = County,text=paste(County)))。然后将ggplotly 称为ggplotly(line_60,tooltip=c("x","y","text"))。为避免标题重叠,请将ggtitle更新为ggtitle(paste("\n",input$sex_,"Older Population (60 or over) in the Selected Counties","\n(2010 to 2050)"))

要移动或移除模式栏组件,请查看How to download a ggplotly plot with R Shiny downloadHandler?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-11
    • 2022-01-21
    • 2017-07-27
    • 1970-01-01
    • 1970-01-01
    • 2013-07-08
    • 2020-10-25
    • 1970-01-01
    相关资源
    最近更新 更多