【发布时间】:2017-06-09 04:49:05
【问题描述】:
我在 R shiny 中生成了两个图,但目前这两个图相互重叠。如何调整它们之间的距离?这是我的 ui.R 和 server.R 代码以及从中生成的图片
ui.R
library(shiny)
library(leaflet)
shinyUI(fluidPage(
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
selectInput("n", label = "Select K for display", choices = c("2", "3", "4")),
checkboxInput("show", "Flood_path")
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("preImage"),
leafletOutput("map")
)
)
))
服务器.R
library(shiny)
shinyServer(function(input, output, session) {
output$preImage <- renderImage({
# When input$n is 3, filename is ./images/image3.jpeg
filename <- normalizePath(file.path('./images', paste('image', input$n, '.jpeg', sep='')))
# Return a list containing the filename and alt text
list(src = filename, alt = paste("Image number", input$n))
}, deleteFile = FALSE)
# Switch for Structure
dt <- reactive(
switch(input$n,
"2" = data_K2$Structure.2,
"3" = data_K2$Structure.3,
"4" = data_K2$Structure.4))
# Map
output$map <- renderLeaflet(
leaflet(data = data_K2) %>% addTiles() %>% setView(lng = mean(data_K2$Long), lat = mean(data_K2$Lat), zoom = 4) %>%
addCircleMarkers(lat = ~Lat, lng = ~Long, popup = ~Location_discription, radius=2, color = ~dt(), fill = TRUE) %>%
addPolylines(group="markers", lng = data_fp$Long, lat = data_fp$Lat, col = "red", weight = 2, opacity = 0.5)
)
【问题讨论】:
-
你可以试试 splitLayout()
-
@MLavoie 试过但没用