更改闪亮的 rglwidget 的绘图大小

Change plot size of rglwidget in shiny

我想将这些图拉伸到 window 大小或至少使它们更大:

ui.R
options(rgl.useNULL = TRUE)
library(shiny)
library(rgl)

shinyUI(fluidPage(
        tabPanel("Ray", 
                  mainPanel(
                    fluidRow(
                      splitLayout(cellWidths = c("60%", "60%")
                                  , cellArgs = list(style = "padding: 6px")
                                  , rglwidgetOutput("ray", width = 300, height = 300)
                                  , rglwidgetOutput("ray2", width = "300px", height = "300px")
                                  )
                            ),
                    fluidRow(
                      splitLayout(cellWidths = c("60%", "60%")
                                  , cellArgs = list(style = "padding: 6px")
                                  , rglwidgetOutput("ray3", width = 300, height = 300)
                                  , rglwidgetOutput("ray4", width = 300, height = 300)
                      )
                    )
                  )
        )
))

server.R
library(threejs)
library(rgl)
library(shiny)
library(car)
library(plot3D)
library(rayshader)

shinyServer(function(input, output) {

 output$ray <- renderRglwidget({
    try(rgl.close())

    ggdiamonds = ggplot(df_surf, aes(Inj_D, Inj_L)) +
    stat_density_2d(aes(fill = stat(nlevel))
                    , geom = "polygon"
                    , n = 200
                    , bins = 50
                    ,contour = TRUE) +
    facet_wrap(Tube~.) +
    scale_fill_viridis_c(option = "A") + theme_bw()
    
    options("cores"=2)
    plot_gg(ggdiamonds, multicore = TRUE)
    rglwidget()
  })
  
  
  output$ray2 <- renderRglwidget({
    try(rgl.close())
    
    ggdiamonds = ggplot(df_surf, aes(Con_D, Con_L)) +
      stat_density_2d(aes(fill = stat(nlevel))
                      , geom = "polygon"
                      , n = 200
                      , bins = 50
                      ,contour = TRUE) +
      facet_wrap(Tube~.) +
      scale_fill_viridis_c(option = "A") + theme_bw()
    
    options("cores"=2)
    plot_gg(ggdiamonds, multicore = TRUE
            , scale = 250
            )
    rglwidget()
  })
  
  output$ray3 <- renderRglwidget({
    try(rgl.close())
    
    ggdiamonds = ggplot(df_surf, aes(Inj_D, Inj_L)) +
      geom_point(aes(
                   colour = Dose
                   , size = Fil
                   )) +
      theme_bw() +
      scale_size_continuous(range = c(2, 6)) +
      scale_fill_viridis_c(option = "inferno") +
      scale_colour_viridis_c(option = "inferno")
    
    options("cores"=2)
    plot_gg(ggdiamonds, multicore = TRUE, scale = 250)
    rglwidget()
  })
  
  output$ray4 <- renderRglwidget({
    try(rgl.close())
    ggdiamonds = ggplot(df_surf, aes(Con_D, Con_L)) +
      geom_point(aes(
        colour = Dose
        , size = Fil
      )) +
      theme_bw() +
      scale_size_continuous(range = c(2, 6)) +
      scale_fill_viridis_c(option = "inferno") +
      scale_colour_viridis_c(option = "inferno")
    
    options("cores"=2)
    plot_gg(ggdiamonds, multicore = TRUE, scale = 250)
    rglwidget()
  })

})

我尝试了很多,但到目前为止我都没有成功。

编辑:数据:

> dput(df_surf)
structure(list(Tube = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 
3L, 3L, 3L), .Label = c("324", "397", "423"), class = "factor"), 
    Date = structure(c(1593648000, 1593648000, 1593648000, 1593648000, 
    1593648000, 1593648000, 1593648000, 1593648000, 1593648000, 
    1593648000, 1593648000, 1593648000, 1593648000, 1593648000, 
    1593648000, 1593648000, 1593648000, 1593648000, 1593648000, 
    1593648000, 1593648000, 1593648000, 1593648000, 1593648000, 
    1593648000, 1593648000, 1593648000, 1593648000, 1578614400, 
    1578614400, 1578614400, 1578614400, 1578614400, 1578614400, 
    1578614400, 1578614400, 1578614400, 1578614400, 1578614400, 
    1578614400, 1578614400, 1578614400, 1578614400, 1578614400, 
    1578614400, 1578614400, 1578614400, 1578614400, 1578614400, 
    1504137600, 1504137600, 1504137600, 1504137600, 1504137600, 
    1504137600, 1504137600, 1504137600, 1504137600, 1504137600, 
    1504137600, 1504137600, 1504137600, 1504137600, 1504137600, 
    1504137600, 1504137600, 1504137600, 1504137600, 1504137600, 
    1504137600, 1504137600, 1504137600, 1504137600, 1551139200, 
    1551139200, 1551139200, 1551139200, 1551139200, 1551139200, 
    1551139200, 1551139200, 1551139200, 1551139200, 1551139200, 
    1551139200, 1551139200, 1551139200, 1551139200, 1551139200, 
    1551139200, 1551139200, 1551139200, 1551139200, 1551139200, 
    1551139200, 1551139200, 1551139200, 1551139200, 1551139200, 
    1551139200, 1551139200, 1551139200, 1551139200, 1551139200, 
    1551139200, 1551139200, 1551139200, 1551139200, 1551139200, 
    1551139200, 1551139200, 1551139200, 1551139200, 1551139200, 
    1551139200, 1551139200, 1551139200, 1551139200, 1551139200, 
    1551139200, 1551139200, 1551139200, 1551139200, 1551139200, 
    1551139200, 1551139200, 1551139200, 1551139200, 1551139200, 
    1551139200, 1551139200, 1551139200, 1551139200, 1551139200, 
    1551139200, 1551139200, 1551139200, 1551139200, 1551139200, 
    1569542400, 1569542400, 1569542400, 1569542400, 1569542400, 
    1569542400, 1569542400, 1569542400, 1569542400, 1569542400, 
    1569542400, 1569542400, 1569542400, 1569542400, 1569542400, 
    1569542400, 1569542400, 1569542400, 1569542400, 1569542400, 
    1569542400, 1569542400, 1569542400, 1569542400, 1569542400, 
    1569542400, 1593561600, 1593561600, 1593561600, 1593561600, 
    1593561600, 1593561600, 1593561600, 1593561600, 1593561600, 
    1593561600, 1593561600, 1593561600, 1593561600, 1593561600, 
    1593561600, 1593561600, 1593561600, 1593561600, 1593561600, 
    1593561600, 1593561600, 1593561600, 1593561600, 1593561600, 
    1593561600, 1593561600, 1593561600, 1593561600, 1592265600, 
    1592265600, 1592265600, 1592265600, 1592265600, 1592265600, 
    1592265600, 1592265600, 1592265600, 1592265600, 1592265600, 
    1592265600, 1592265600, 1592265600, 1592265600, 1592265600, 
    1592265600, 1592265600, 1592265600, 1592265600, 1592265600, 
    1592265600, 1592265600, 1592265600, 1592265600), class = c("POSIXct", 
    "POSIXt"), tzone = "UTC"), Tune_D = c(-2.84, -2.84, -2.84, 
    -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, 
    -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, 
    -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, 
    -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, 
    -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, -2.84, 
    -2.84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 
    Tune_L = c(0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 
    0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 
    0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 
    0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 
    0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 0.45, 
    0.45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 
    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
    10), EXP_D = c(4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 
    4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 
    4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 
    4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 4.2, 
    4.2, 4.2, 4.2, 4.2, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 
    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 
    5, 5, 5, 5), EXP_L = c(10.91, 10.91, 10.91, 10.91, 10.91, 
    10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 
    10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 
    10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 
    10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 
    10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 10.91, 12.5, 
    12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
    12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
    12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
    12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
    12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
    12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
    12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
    12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 
    12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 12.5, 13, 
    13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 
    13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 12.7, 12.7, 12.7, 
    12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 
    12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 
    12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 
    12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 
    12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7, 12.7
    ), T_AB = c(540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 600, 600, 600, 600, 600, 600, 600, 600, 
    600, 600, 600, 600, 600, 600, 600, 600, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, 
    540, 540, 540, 540, 540), Fil = c(12000, 11800, 11600, 11400, 
    11200, 11000, 10800, 10600, 10400, 10200, 10400, 10200, 10000, 
    9800, 9600, 9400, 9200, 9000, 8800, 8600, 8400, 8200, 8000, 
    7800, 7600, 7400, 7200, 7000, 12000, 11800, 11600, 11400, 
    11200, 11000, 10800, 10600, 10400, 10200, 10000, 9800, 9600, 
    9400, 9200, 9000, 8800, 8600, 8400, 8200, 8000, 12600, 12400, 
    12200, 12000, 11800, 11600, 11400, 11200, 11000, 10800, 10600, 
    10400, 10200, 10000, 9800, 9600, 9400, 9200, 9000, 8800, 
    8600, 8400, 8200, 8000, 10000, 9800, 9600, 9400, 9200, 9000, 
    8800, 8600, 8400, 8200, 8000, 7800, 7600, 7400, 7200, 7000, 
    12000, 11800, 11600, 11400, 11200, 11000, 10800, 10600, 10400, 
    10200, 10000, 9800, 9600, 9400, 9200, 9000, 8800, 8600, 8400, 
    8200, 8000, 7800, 7600, 7400, 7200, 7000, 11600, 11400, 11200, 
    11000, 10800, 10600, 10400, 10200, 10000, 9800, 9600, 9400, 
    9200, 9000, 8800, 8600, 8400, 8200, 8000, 7800, 7600, 7400, 
    7200, 7000, 12000, 11800, 11600, 11400, 11200, 11000, 10800, 
    10600, 10400, 10200, 10000, 9800, 9600, 9400, 9200, 9000, 
    8800, 8600, 8400, 8200, 8000, 7800, 7600, 7400, 7200, 7000, 
    12400, 12200, 12000, 11800, 11600, 11400, 11200, 11000, 10800, 
    10600, 10400, 10200, 10000, 9800, 9600, 9400, 9200, 9000, 
    8800, 8600, 8400, 8200, 8000, 7800, 7600, 7400, 7200, 7000, 
    10900, 10900, 10800, 10700, 10600, 10500, 10400, 10300, 10200, 
    10100, 10000, 9900, 9800, 10600, 10500, 10400, 10300, 10200, 
    10100, 10000, 9900, 9800, 9700, 9600, 9500), Inj_D = c(18, 
    18.05, 18, 18, 18.3, 18.3, 18.6, 18.6, 18.6, 18.6, 18.9, 
    18.9, 18.85, 18.05, 18.3, 18, 19.3, 18.05, 17.95, 19.75, 
    18, 19.85, 18.05, 20.25, 18.3, 18, 19.55, 18, 18, 18, 18, 
    18, 18, 18.35, 18.65, 18.65, 18.95, 19.15, 19.5, 18.85, 18, 
    18, 17.9, 17.95, 17.95, 17.95, 18, 18.3, 18, 17.6, 17.75, 
    18, 18.25, 18.6, 18.55, 18.65, 18.3, 18.65, 19.25, 19.2, 
    19.45, 19.55, 19.7, 19.8, 19.75, 19.85, 20.1, 20.1, 20.25, 
    20.4, 20.4, 20.45, 20.45, 19.25, 19.45, 19.8, 19.8, 20, 20.15, 
    20.25, 20.45, 20.15, 20.1, 20.4, 20.65, 20.45, 20.65, 20.7, 
    20.7, 18, 17.95, 17.95, 18.25, 18.35, 18.6, 18.35, 18.75, 
    19, 19.15, 19.4, 19.4, 19.65, 19.85, 20.15, 20.1, 20.4, 20.15, 
    20.2, 20.35, 20.35, 20.45, 20.85, 20.75, 20.85, 20.65, 18.05, 
    18.2, 18.3, 18.55, 18.9, 18.9, 19.2, 19.25, 19.35, 19.5, 
    19.8, 19.85, 20, 20, 20.45, 20.45, 20.1, 20.25, 20.35, 20.4, 
    20.5, 20.9, 20.85, 20.75, 17.7, 16.95, 17, 17.85, 18.2, 18.5, 
    17.85, 18.2, 18.7, 19.05, 19.1, 19.35, 19.35, 19.55, 19.75, 
    19.8, 19.7, 20.1, 20.3, 20.4, 20.4, 20.1, 20.2, 20.25, 19.8, 
    16.95, 17.45, 17.45, 17.2, 17.5, 17.8, 17.8, 17.5, 17.8, 
    18.4, 18.7, 19, 19, 19, 19.3, 19.3, 19.6, 19.6, 19.9, 19.9, 
    20.2, 20.25, 20.2, 20.25, 20.4, 20.55, 20.55, 20.6, 20.7, 
    19.6, 19.6, 19.3, 19.3, 19.3, 19.6, 19.6, 19.6, 19.6, 19.9, 
    19.9, 20.2, 20.2, 18.95, 19.35, 19.2, 19.6, 19.6, 19.75, 
    19.9, 19.95, 19.95, 19.9, 20.05, 20.15), Con_D = c(-4.35, 
    -4.2, -4.3, -4.3, -4.3, -4.3, -4.3, -4.3, -4.3, -4.3, -4.3, 
    -4.3, -4.35, -4.25, -4.4, -4.3, -4.3, -4.3, -4.35, -4.15, 
    -4.3, -4.2, -4.4, -4.05, -4.3, -4.35, -4.3, -4.15, -4.35, 
    -4.35, -4.25, -4.35, -4.35, -4.35, -4.2, -4.25, -4.3, -4.35, 
    -4.15, -4.3, -4.25, -4.3, -4.35, -4.3, -4.2, -4.35, -4.25, 
    -4.3, -4.25, -4.45, -4.3, -4.5, -4.5, -4.55, -4.55, -4.6, 
    -4.45, -4.4, -4.5, -4.5, -4.45, -4.55, -4.5, -4.6, -4.45, 
    -4.45, -4.55, -4.55, -4.7, -4.45, -4.45, -4.35, -4.6, -4.25, 
    -4.1, -4.25, -4.55, -4.15, -4.3, -4.4, -4.35, -4.25, -4.25, 
    -4.25, -4.35, -4.45, -4.25, -4.55, -4.55, -4.3, -4.25, -4.35, 
    -4.2, -4.3, -4.25, -4.25, -4.4, -4.35, -4.1, -4.25, -4.35, 
    -4.2, -4.2, -4.3, -4.3, -4.3, -4.25, -4.15, -4.3, -4.2, -4.2, 
    -3.95, -4.35, -4.4, -4.35, -4.2, -4.3, -4.25, -4.3, -4.25, 
    -4.55, -4.25, -4.3, -4.3, -4.3, -4.3, -4.25, -4.15, -4.1, 
    -4.3, -4.25, -4.45, -4.05, -4.2, -4.25, -4.3, -4.5, -4.4, 
    -4.55, -3.95, -4, -3.9, -4.15, -3.9, -4.15, -4.15, -4.2, 
    -4.2, -4.15, -4.1, -4, -3.85, -4.15, -3.95, -3.85, -4.1, 
    -3.7, -3.7, -3.85, -3.55, -3.9, -3.3, -3.9, -3.9, -4.2, -4.05, 
    -3.75, -4.1, -4, -4, -4, -4, -4, -3.75, -3.75, -4, -4, -3.75, 
    -4, -4, -3.75, -4, -3.75, -4, -3.75, -3.7, -3.95, -3.95, 
    -3.9, -4, -4.05, -3.65, -3.85, -4, -4, -3.75, -4, -4, -3.75, 
    -4, -4, -4, -3.95, -3.75, -4, -3.8, -4, -3.8, -4, -3.95, 
    -3.75, -4.2, -4.05, -3.95, -4.05, -4, -4, -4.05), Con_L = c(0.7, 
    0.35, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 0.65, 0.7, 0.7, 
    0.85, 1.3, 0.7, 0.7, 0.7, 0.65, 0.2, 1.45, 0.2, 0.95, 0.05, 
    1.55, 0.65, 0.3, 0.7, 0.3, 0.7, 0.7, 0.7, 0.7, 0.7, 0.7, 
    0.65, 0.75, 0.65, 0.75, 1, 1.05, 0.9, 0.7, 0.8, 0.7, 0.7, 
    0.75, 0.6, 0.7, 0.65, 1.5, 1.2, 1.15, 1, 1.15, 0.9, 0.9, 
    0.9, 0.85, 0.95, 1.2, 0.95, 1.15, 1.2, 1.25, 1.3, 1.3, 1.2, 
    1.4, 1.7, 1.55, 1.65, 1.6, 1.8, 0.8, 0.8, 0.9, 1.15, 1.2, 
    1, 1.5, 1.5, 0.9, 0.95, 0.95, 1.6, 1.2, 1.15, 1.2, 1.2, 1.2, 
    1.2, 0.7, 0.7, 0.6, 0.6, 0.6, 0.65, 0.6, 0.8, 0.75, 1.05, 
    0.95, 0.95, 0.95, 0.95, 1.5, 0.95, 0.95, 0.95, 0.95, 0.95, 
    1.5, 1.2, 1.6, 1.5, 0.6, 0.7, 0.55, 0.55, 0.65, 0.9, 0.75, 
    0.75, 0.85, 0.9, 0.95, 0.95, 1.2, 1.3, 1.55, 1.55, 0.9, 0.9, 
    0.95, 0.95, 0.95, 1.6, 1.55, 1.25, 1.15, 0.95, 0.9, 0.75, 
    0.75, 0.8, 0.6, 0.8, 0.55, 0.7, 0.6, 0.75, 0.9, 0.95, 0.85, 
    1.25, 1, 1.15, 1.3, 1.35, 1.45, 1.05, 1.3, 1.2, 0.5, 0.3, 
    1.1, 1.25, 1.05, 1.05, 1.1, 1.1, 0.85, 0.6, 0.85, 0.6, 0.6, 
    0.6, 1.1, 0.85, 0.85, 1.1, 0.85, 0.85, 0.85, 0.85, 0.85, 
    0.8, 0.85, 0.85, 0.85, 0.85, 0.85, 0.95, 0.85, 0.85, 0.85, 
    1.1, 1.1, 1.1, 1.1, 1.1, 1.2, 1.2, 1.2, 1.2, 1.25, 1.05, 
    1.25, 1, 1.05, 1.1, 1, 1.05, 0.95, 0.95, 0.85, 0.95, 0.95
    ), Inj_L = c(2.5, 2.52, 2.52, 2.5, 2.52, 2.48, 2.5, 2.48, 
    2.44, 2.38, 2.48, 2.42, 2.4, 2.24, 2.38, 2.52, 2.5, 2.48, 
    2.1, 2.4, 2.12, 2.44, 2.08, 2.34, 2.22, 2.52, 2.24, 2.14, 
    2.5, 2.5, 2.52, 2.52, 2.5, 2.5, 2.5, 2.48, 2.46, 2.5, 2.38, 
    2.38, 2.24, 2.52, 2.48, 2.5, 2.44, 2.5, 2.42, 2.5, 2.46, 
    2.46, 2.38, 2.48, 2.46, 2.5, 2.5, 2.5, 2.5, 2.48, 2.5, 2.48, 
    2.48, 2.52, 2.5, 2.52, 2.44, 2.46, 2.52, 2.52, 2.52, 2.44, 
    2.4, 2.34, 2.42, 2.44, 2.38, 2.5, 2.52, 2.4, 2.52, 2.5, 2.48, 
    2.4, 2.38, 2.42, 2.44, 2.48, 2.4, 2.52, 2.5, 2.5, 2.44, 2.46, 
    2.4, 2.4, 2.44, 2.5, 2.46, 2.48, 2.36, 2.48, 2.46, 2.46, 
    2.48, 2.52, 2.52, 2.48, 2.4, 2.36, 2.44, 2.38, 2.38, 2.26, 
    2.44, 2.42, 2.38, 2.42, 2.5, 2.4, 2.42, 2.46, 2.52, 2.5, 
    2.5, 2.44, 2.42, 2.5, 2.5, 2.42, 2.36, 2.48, 2.44, 2.5, 2.32, 
    2.38, 2.42, 2.44, 2.52, 2.46, 2.52, 2.24, 2.32, 2.38, 2.32, 
    2.3, 2.46, 2.46, 2.5, 2.38, 2.42, 2.32, 2.36, 2.2, 2.34, 
    2.26, 2.16, 2.3, 2.18, 2.16, 2.24, 2.06, 2.2, 1.86, 2.16, 
    2.36, 2.26, 2.4, 2.08, 2.32, 2.28, 2.3, 2.3, 2.3, 2.28, 2.12, 
    2.16, 2.32, 2.32, 2.22, 2.26, 2.32, 2.18, 2.3, 2.2, 2.3, 
    2.2, 2.18, 2.32, 2.28, 2.26, 2.32, 2.34, 2.14, 2.22, 2.3, 
    2.3, 2.18, 2.3, 2.26, 2.2, 2.32, 2.32, 2.24, 2.2, 2.1, 2.26, 
    2.14, 2.26, 2.18, 2.26, 2.28, 2.16, 2.4, 2.34, 2.28, 2.32, 
    2.32, 2.3, 2.32), Dose = c(56, 56, 279, 253, 278, 260, 256, 
    218, 171, 122, 188, 154, 126, 100, 46, 32, 30, 24, 16, 57, 
    15, 33, 17, 41, 16, 16, 15, 17, 214, 214, 217, 243, 228, 
    228, 230, 189, 168, 138, 117, 78, 58, 51, 49, 37, 30, 27, 
    25, 21, 18, 172, 224, 259, 278, 285, 294, 299, 300, 301, 
    309, 301, 274, 265, 257, 252, 267, 256, 244, 234, 235, 221, 
    207, 195, 184, 373, 354, 318, 313, 318, 282, 290, 272, 217, 
    204, 190, 190, 167, 154, 329, 329, 211, 214, 234, 250, 279, 
    288, 284, 297, 293, 300, 284, 270, 261, 251, 236, 223, 229, 
    190, 182, 170, 159, 146, 147, 127, 121, 106, 241, 257, 281, 
    292, 288, 296, 286, 296, 292, 272, 256, 261, 254, 247, 230, 
    227, 184, 177, 165, 150, 143, 144, 131, 114, 138, 136, 167, 
    216, 246, 266, 265, 295, 326, 309, 307, 299, 286, 270, 247, 
    252, 223, 242, 234, 221, 202, 147, 148, 127, 50, 26, 95, 
    112, 235, 246, 242, 251, 267, 274, 282, 296, 296, 316, 302, 
    298, 318, 309, 303, 294, 267, 251, 241, 210, 203, 190, 180, 
    166, 156, 147, 282, 280, 251, 261, 258, 250, 247, 240, 241, 
    245, 258, 240, 241, 331, 318, 322, 322, 319, 324, 315, 315, 
    320, 297, 303, 303)), row.names = c(NA, -218L), class = "data.frame")

你必须在 plot_gg 中使用 widthheightzoom(注意:较小的缩放值会增加图像)。

library(shiny)
library(ggplot2)
library(rayshader)
library(rgl)
library(magick)

options(rgl.useNULL = TRUE)

ui <- fluidPage(
  fluidRow(
    column(
      6,
      rglwidgetOutput("ray1", width = "45vw", height = "45vh")
    ),
    column(
      6,
      rglwidgetOutput("ray2", width = "45vw", height = "45vh")
    )
  ),
  fluidRow(
    column(
      6,
      rglwidgetOutput("ray3", width = "45vw", height = "45vh")
    ),
    column(
      6,
      rglwidgetOutput("ray4", width = "45vw", height = "45vh")
    )
  )
)

server <- function(input, output) {

  ggdiamonds <- ggplot(df_surf, aes(Inj_D, Inj_L)) +
    geom_point(aes(colour = Dose, size = Fil)) +
    theme_bw() +
    scale_size_continuous(range = c(2, 6)) +
    scale_colour_viridis_c(option = "inferno")
  
  output$ray1 <- renderRglwidget({
    try(close3d())
    plot_gg(
      ggdiamonds, width=4, height=4, scale = 150, zoom = 0.8
    )
    rglwidget()
  })
  output$ray2 <- renderRglwidget({
    try(close3d())
    plot_gg(
      ggdiamonds, width=4, height=4, scale = 150, zoom = 0.8
    )
    rglwidget()
  })
  output$ray3 <- renderRglwidget({
    try(close3d())
    plot_gg(ggdiamonds, width=4, height=4, scale = 150, zoom = 0.8)
    rglwidget()
  })
  output$ray4 <- renderRglwidget({
    try(close3d())
    plot_gg(
      ggdiamonds, width=4, height=4, scale = 150, zoom = 0.8
    )
    rglwidget()
  })
  
}

shinyApp(ui, server)