удалить разрыв между графиками в Plotly - PullRequest
2 голосов
/ 15 января 2020

Я настраиваю размер диаграммы в блестящем, но все еще имею пустую область между диаграммами

они показывают как старую область до высоты и ширины конфигурации

enter image description here

это мой код

plot1_reactive <- eventReactive(input$submit_but,{
      xaxis <- list(
                    tickformat = "%-d/%-m/%Y",
                    type='category'
                    )
      yaxis <- list(title = input$sel_par1)
      r <- plot_ly(mydata,x=date,y = a , type = 'scatter', mode = 'lines+markers'
                   , width = 950, height = 200,line = list(shape = "linear"))%>%
      layout(xaxis = xaxis, yaxis = yaxis) 

    })
    plot2_reactive <- eventReactive(input$submit_but,{
      xaxis <- list(
                    tickformat = "%-d/%-m/%Y",
                    type='category')
      yaxis <- list(title = input$sel_par2)
      r <- plot_ly(mydata,x=date,y = b , type = 'scatter', mode = 'lines+markers'
                   , width = 950, height = 200,line = list(shape = "linear"))%>%
        layout(autosize = F,xaxis = xaxis, yaxis = yaxis)  
    })

1 Ответ

2 голосов
/ 20 января 2020

Добро пожаловать в stackoverflow!

Вам необходимо установить аргумент height для plotlyOutput (UI) вместо аргумента в вашем вызове plot_ly (сервер). В противном случае будет применяться значение по умолчанию 400px.

Пожалуйста, смотрите следующий воспроизводимый пример:

library(shiny)
library(plotly)

ui <- fluidPage(
  plotlyOutput("p1Out", height = "200px"),
  plotlyOutput("p2Out", height = "200px"),
  plotlyOutput("p3Out", height = "200px")
)

server <- function(input, output, session) {
  output$p3Out <- output$p2Out <- output$p1Out <- renderPlotly({
    plot_ly(y=1:10, type = "scatter", mode = "lines+markers")
  })
}

shinyApp(ui, server)

enter image description here

...