Skip to content Skip to sidebar Skip to footer

Shiny R Scale Down Plotoutput

I'm trying to scale down a plotOutput with Shiny R. I have this plot: from this code: #In ui: fluidRow( column(width = 12, h4('Diagrama Persistencia'),

Solution 1:

Since you didn't provide a reproducible example, see if this example helps you. Based on https://stackoverflow.com/a/8839678/4190526

The key is the following line, which finds the image under the div with the id distPlot (i.e. the plot name in ui.R), and define the CSS with a max-height but otherwise auto.

tags$style(HTML("div#distPlotimg {width:auto;height:auto;max-width:auto;max-height:400px;}")),

Full code

library(shiny)

ui <- shinyUI(fluidPage(

   tags$style(HTML("div#distPlot img {width: auto; height: auto; max-width: auto; max-height: 400px;}")),
   titlePanel("Old Faithful Geyser Data"),
   sidebarLayout(
      sidebarPanel(
         sliderInput("bins",
                     "Number of bins:",
                     min = 1,
                     max = 50,
                     value = 30)
      ),
      mainPanel(
         plotOutput("distPlot")
      )
   )
))

server <- shinyServer(function(input, output) {

   output$distPlot <- renderPlot({
      x    <- faithful[, 2] 
      bins <- seq(min(x), max(x), length.out = input$bins + 1)

      hist(x, breaks = bins, col = 'darkgray', border = 'white')
   }, width=600, height=1200)
})

shinyApp(ui = ui, server = server)

Post a Comment for "Shiny R Scale Down Plotoutput"