r - 如何在 Shiny 的tabsetpanel和图形之间创建间距?

标签 r graph shiny

我使用 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")
    })

  }
))

enter image description here

关于r - 如何在 Shiny 的tabsetpanel和图形之间创建间距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47589335/

相关文章:

r - 使用 LightGBM 进行多分类

r - 取消列出并拆分列以添加到行而不会丢失 R 中其他列的信息

python - 您可以将四分位距绘制为 seaborn 线图上的误差带吗?

r - 根据r中的列名从列表中提取数据框

mysql - 如何使用 R 将 Twitter 数据发送到 SQL 数据库

c++ - 构建图形的最佳标准数据结构是什么?

java - 优化网络图形绘制

r - 无法在 R Shiny flexdashboard 中并排绘制条形图

r - 如何生成一个 URL 来恢复 Shiny 中的用户输入值

javascript - 将 Shiny unbindAll 和 bindAll 仅限于 HTML 元素