有没有办法将一个R图在一个tabPanel中居中闪亮?

use*_*688 4 r shiny

我正在制作一个闪亮的应用程序,我的方式格式化的情节太宽了.我用width参数缩短了它们,所以它们看起来很合理,但我无法弄清楚如何将它们置于选项卡面板中(显然plotOutput没有采用align参数).

 tabsetPanel( 
     tabPanel("Plot1", plotOutput("plot1", width="60%")),
     tabPanel("Plot2", plotOutput("plot2", width="60%"))
   )
Run Code Online (Sandbox Code Playgroud)

zer*_*323 5

我不知道任何闪亮的具体方式,但你总是可以使用CSS来设置输出图像的样式.只需tags$style在您的用户界面中添加以下内容:

"#plot1 img, #plot2 img {
    width: 60%;
    display: block;
    margin-left: auto;
    margin-right: auto;
}"
Run Code Online (Sandbox Code Playgroud)

width="60%"从中删除plotOutput.排除width它只是一个Bootstrap中心块类.最小的ui定义可能如下所示:

shinyUI(bootstrapPage(
    tags$head(tags$style(
        type="text/css",
        "#plot1 img, #plot2 img {
            width: 60%;
            display: block;
            margin-left: auto;
            margin-right: auto;
        }"
    )),
    tabsetPanel(
        tabPanel("Plot1", plotOutput("plot1")),
        tabPanel("Plot2", plotOutput("plot2"))
    )
))
Run Code Online (Sandbox Code Playgroud)