【问题标题】:Adjusting leaflet height in flexdashboard在 flexdashboard 中调整传单高度
【发布时间】:2021-10-17 23:10:32
【问题描述】:

我正在尝试在 .rmd 文件中发布闪亮的视觉效果。我的代码运行,但是当我运行 .rmd 文件时,输出传单被压缩。关于如何让这个“更高”的任何见解?


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)

【问题讨论】:

  • 您能否尝试创建一个重现您的问题的示例?这将使您更容易获得帮助——请参阅stackoverflow.com/questions/5963269/… ps 您的代码中没有传单地图。
  • 您的代码不可重现,请定义您从哪里获得yeardataset_new 等。

标签: r shiny leaflet shinyapps flexdashboard


【解决方案1】:

解决此问题的方法是在 ui 部分的输出中添加一个特定的高度。

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

现在你没有使用 renderleaflet ,所以你可以试试:

 plotOutput("plot1", height = "400px")

【讨论】:

    猜你喜欢
    • 2021-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-26
    • 1970-01-01
    • 2021-09-26
    • 2015-03-14
    • 1970-01-01
    相关资源
    最近更新 更多