R Shiny布局
在闪亮的仪表板上,我目前正在绘制1个条形图,并在下面绘制4个饼图,如下所示:
In my shiny dashboard, I am currently plotting 1 bar graph above, and 4 pie charts below, as follows:
fluidRow(
column(12, plotOutput("bar1"))),
fluidRow(
column(3, plotOutput("pie")),
column(3, plotOutput("pie2")),
column(3, plotOutput("pie3")),
column(3, plotOutput("pie4")))
如何将条形图与4个饼图并排成正方形?
How would I go about plotting the bar chart alongside the 4 pie charts, with the pie charts arranged in a square?
有效地,条形图将是column(6,...
,所有饼图将是column(3,...
,但是我需要条形图扩展到两行,以便将饼形图直接绘制在其旁边.
Effectively the bar chart would be column(6,...
and all of the pie charts would be column(3,...
but I would need the bar chart to extend to 2 rows so the pie charts are plotted directly beside it.
标准plotOutput
的高度为400px
plotOutput(outputId,width ="100%",height ="400px",单击= NULL,
dblclick = NULL,悬停= NULL,hoverDelay = NULL,hoverDelayType = NULL,brush = NULL,clickId = NULL,hoverId = NULL,内联= FALSE)
plotOutput(outputId, width = "100%", height = "400px", click = NULL,
dblclick = NULL, hover = NULL, hoverDelay = NULL, hoverDelayType = NULL, brush = NULL, clickId = NULL, hoverId = NULL, inline = FALSE)
因此您可以执行以下操作:
So you can do the following:
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)