我使用 tabsetpanel()
函数为两个不同的图表创建选项卡。但是,我遇到了图表标题非常靠近选项卡并且没有任何间距的问题。看起来它被挤在一起了,所以我想知道如何在选项卡面板和图形之间创建间距?我在左侧有一个 Shiny 的小部件,它控制着右侧的图形。这是我的代码示例:
tabPanel("Name",
sidebarLayout(
sidebarPanel(
selectInput(
<shiny widget coding is here>
)
),
mainPanel(
tabsetPanel(
tabPanel("graphname", plotlyOutput("graph1")),
tabPanel("graphname2", plotlyOutput("graph2"))
)
)
)
)
所以你可以看到有 tabsetPanel,然后是有图表的 tabpanel。但是图表和 tabsetpanel bar 之间没有间距,看起来像这样:
我该如何解决这个问题?
最佳答案
又快又脏,在情节之前使用 br()
。 br()
是 HTML 换行符:
library(shiny)
library(plotly)
runApp(list(
ui = fluidPage(tabPanel("Name",
sidebarLayout(
sidebarPanel(
),
mainPanel(
tabsetPanel(
tabPanel("graphname", br(), plotlyOutput("graph1")),
tabPanel("graphname2", plotlyOutput("graph2"))
)
)
)
)),
server = function(input, output) {
output$graph1 <- renderPlotly({
plot_ly(mtcars)%>% layout(title = "With Space")
})
output$graph2 <- renderPlotly({
plot_ly(mtcars)%>% layout(title = "Without Space")
})
}
))
关于r - 如何在 Shiny 的tabsetpanel和图形之间创建间距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47589335/