[英]Is there a way to center an R plot within a tabPanel in shiny?
我正在制作一个闪亮的应用程序,我的方式格式化的情节太宽了。 我用width参数缩短了它们,所以它们看起来很合理,但我无法弄清楚如何将它们置于选项卡面板中(显然plotOutput没有采用align参数)。
tabsetPanel(
tabPanel("Plot1", plotOutput("plot1", width="60%")),
tabPanel("Plot2", plotOutput("plot2", width="60%"))
)
我不知道任何闪亮的具体方式,但你总是可以使用CSS来设置输出图像的样式。 只需将带有以下内容的tags$style
添加到您的UI:
"#plot1 img, #plot2 img {
width: 60%;
display: block;
margin-left: auto;
margin-right: auto;
}"
并从plotOutput
删除width="60%"
。 除了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"))
)
))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.