【问题标题】:R Shiny LayoutsR闪亮的布局
【发布时间】:2018-10-04 19:25:31
【问题描述】:

在我闪亮的仪表板中,我目前在上方绘制 1 个条形图,在下方绘制 4 个饼图,如下所示:

fluidRow(
  column(12, plotOutput("bar1"))),
  fluidRow(
    column(3, plotOutput("pie")),
    column(3, plotOutput("pie2")),
    column(3, plotOutput("pie3")),
    column(3, plotOutput("pie4")))

我将如何在 4 个饼图旁边绘制条形图,饼图以正方形排列?

条形图实际上是column(6,...,所有饼图都是column(3,...,但我需要将条形图扩展到两行,以便将饼图直接绘制在它旁边。

【问题讨论】:

    标签: r plot layout shiny fluid-layout


    【解决方案1】:

    标准plotOutput 的高度为400px

    plotOutput(outputId, width = "100%", height = "400px", click = NULL,
    dblclick = NULL,悬停 = NULL,hoverDelay = NULL,hoverDelayType = NULL,brush = NULL,clickId = NULL,hoverId = NULL,inline = FALSE)

    因此您可以执行以下操作:

    library(shiny)
    
    ui <- fluidPage(
      fluidRow(
        column(6, plotOutput("bar1",height = "800px")),
        column(6,
               column(6, plotOutput("pie")),
               column(6, plotOutput("pie2")),
               column(6, plotOutput("pie3")),
               column(6, plotOutput("pie4"))
    
        ))
    )
    
    server <- function(input, output) {
    
      output$bar1 <- renderPlot({
        hist(rnorm(1:100));box();grid()
      })
      output$pie <- renderPlot({
        plot(rnorm(1:100));box();grid()
      })
      output$pie2 <- renderPlot({
        plot(rnorm(1:100));box();grid()
      })
      output$pie3 <- renderPlot({
        plot(rnorm(1:100));box();grid()
      })
      output$pie4 <- renderPlot({
        plot(rnorm(1:100));box();grid()
      })
    }
    
    shinyApp(ui,server)
    

    【讨论】:

      猜你喜欢
      • 2022-10-14
      • 2020-02-03
      • 2020-07-04
      • 2016-11-03
      • 2022-10-04
      • 1970-01-01
      • 1970-01-01
      • 2017-04-04
      • 2016-12-08
      相关资源
      最近更新 更多