如何调整R中两个绘图之间的距离?

如何调整R中两个绘图之间的距离?,r,shiny,R,Shiny,我已经在R中生成了两个绘图,但目前这两个绘图相互重叠。如何调整它们之间的距离?这是我的ui.R和server.R代码,以及由它们生成的图片 用户界面 服务器.R library(shiny) shinyServer(function(input, output, session) { output$preImage <- renderImage({ # When input$n is 3, filename is ./images/image3.jpeg filen

我已经在R中生成了两个绘图,但目前这两个绘图相互重叠。如何调整它们之间的距离?这是我的ui.R和server.R代码,以及由它们生成的图片

用户界面

服务器.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)
  )
我会使用fluidrow:


我才意识到这篇文章有多老。

你可以试试splitLayout@MLavoie我试过了,但没用谢谢你。我会试试看。@upendra,如果这个答案解决了你的问题,请把它记下来。
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)
  )
library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(

   # Application title
   titlePanel("Old Faithful Geyser Data"),

   # Sidebar with a slider input for number of bins 
   fluidRow(column(12,
                   fluidRow(
                     column(2, 
         sliderInput("bins", "Number of bins:", min = 1, max = 50, value = 30)
      ),
      column(10,  plotOutput("distPlot"))
   ),
   fluidRow(column(2),
            column(10, plotOutput("distPlot2")))
)
)
)

# Define server logic required to draw a histogram
server <- function(input, output) {

   output$distPlot <- renderPlot({
      # generate bins based on input$bins from ui.R
      x    <- faithful[, 2] 
      bins <- seq(min(x), max(x), length.out = input$bins + 1)

      # draw the histogram with the specified number of bins
      hist(x, breaks = bins, col = 'darkgray', border = 'white')
   })

   output$distPlot2 <- renderPlot({
     # generate bins based on input$bins from ui.R
     x    <- faithful[, 2] 
     bins <- seq(min(x), max(x), length.out = input$bins + 1)

     # draw the histogram with the specified number of bins
     hist(x, breaks = bins, col = 'darkgray', border = 'white')
   })
}

# Run the application 
shinyApp(ui = ui, server = server)