0

I'm trying publish a Shiny visual in an .rmd file. My code runs, but the output leaflet is compressed when I run the .rmd file. Any insights on how to make this "taller"?

Visual of the problem


ui1 <- fluidPage(
    titlePanel("Temperature per year by State"),
    sidebarLayout(
        sidebarPanel(
            inputPanel(
                selectInput(inputId = "input_year",
                            label = "Which Year do you want to display?",
                            choices = years,
                            selected = years))),
        
        mainPanel(
            plotOutput("plot1")
        )))

grouping <- 
    
    server1 <- function(input, output){
        output$plot1 <- renderPlot({
            ggplot(filter(dataset_new,
                          Year == input$input_year), 
                   mapping = aes(x = long, y = lat, group = group, fill = Average.temp))+
                geom_polygon(color = "black")+
                guides(fill = guide_legend(title = "Temperature\n(F)", 
                                           reverse = T))+
                labs(x = "Longitude",y = "Latitude", 
                     title = "Average temperature by U.S. State")+
                theme(panel.grid.major = element_blank(), 
                      panel.grid.minor = element_blank(),
                      panel.background = element_blank(), 
                      axis.line = element_line(colour = "black"))+
                annotate("text", x = -115, y = 27, label = "***Temperature information for\nNevada, New Mexico and\n Oklahoma was not available") +
                scale_fill_gradient(low = "yellow", high = "red")
        })}

shinyApp(ui = ui1, server = server1)

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Liz
  • 1
  • Can you try to create an example that reproduces your issue; this will make it easier for you to get help -- see https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example ps There is no leaflet map in your code. – user20650 Aug 15 '21 at 17:39
  • Your code is not reproducible, please define where you get the `year`, `dataset_new` etc. – lz100 Aug 26 '21 at 01:32

1 Answers1

0

The solution to this problem is to add a sepecific height to your output ihn the ui part.

leafletOutput("plot1", height = "95vh")

Right now you are not using renderleaflet , so you could try:

 plotOutput("plot1", height = "400px")
pbraeutigm
  • 455
  • 4
  • 8