Centering a plot within a fluidRow in Shiny

前端 未结 2 759
谎友^
谎友^ 2021-02-05 03:58

I have a fluidRow with a plot rendered in one of the columns. I would like to know how to center the plot when I have manually specified the plot width via the renderPlot({crea

相关标签:
2条回答
  • 2021-02-05 04:43

    align="center" can be included within the column expression (not within plotOutput though). e.g.

    fluidRow(
      column(8, align="center",
        plotOutput('plot1')
      )
    )
    
    0 讨论(0)
  • 2021-02-05 04:51

    You could use align="center" as part of your plotOutput() function. So your ui.R would like this:

    ui.R

    setwd("C:/Users/Nate/Documents/R Working Directory/appFolder/example")
    shinyUI(fluidPage(
    titlePanel("Test"),
    sidebarLayout(
    sidebarPanel(
    p('stuff here')
      ),
    mainPanel(
    tabsetPanel(id = 'tabs1',
              tabPanel("main",
                       fluidRow(
                         column(8,
                                plotOutput('plot1',align="center")),
                         column(4,
                                p('2nd column'))),
                       fluidRow(
                       p("2nd row of viewing area"))
                       ),
    
              tabPanel("second",
                   p("main viewing area")),
          tabPanel("third",
                          p('main viewing area')
                       )
    ))
    )
    ))
    
    0 讨论(0)
提交回复
热议问题