Reputation: 119
I config the chart's size in shiny but still have blank area between charts
they show like old area before config height&width
this is my code
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)
})
Upvotes: 2
Views: 265
Reputation: 33580
Welcome to stackoverflow!
You'll need to set the height
argument of plotlyOutput
(UI) instead of the one in your plot_ly
call (server). Otherwise the default of 400px will be applied.
Please see the following reproducible example:
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)
Upvotes: 2