【问题标题】:Rescaling made the plots blurry - shiny fluidrow重新缩放使图变得模糊 - 闪亮的流体行
【发布时间】:2017-04-26 13:41:15
【问题描述】:

我的目标是将页面分为四个象限,每个象限都有一组单独的图。

我准备好了一个象限。当它占据整个窗口时看起来不错。我想在一个页面上有 4 个这样的窗格。正如您从(两个上象限的)屏幕截图中看到的那样,将已经准备好的窗格插入左上象限会导致一些非常模糊的东西。我怎样才能让图表不变得模糊?

我使用了fluidrow,也许这不是一个好主意?

ui = fluidPage(

  fluidRow(
    column(6,

           fluidRow(
             column(8, plotOutput("barChart1", height = 250))
             , column(4, plotOutput("compteur1", height = 250))
           )

           ,fluidRow(
             column(3,
                    dateRangeInput(
                      "dateRange2",
                      label = "Choose the window:",
                      start = "2016-09-01"
                    ) 
             )
             , column(3, 
                      selectInput("security", "Index:", selected = worldindices[1]
                                  , list(`World Indices` = worldindices,
                                         `Regional Indices` = regionIndices,
                                         `Country Indices` = countryIndices)
                      )  
             )
             , column(3, 
                      selectInput("metric", "Metric:", selected = plainMetrics[1]
                                  , list(plainMetrics
                                         , `Valuation Multiples` = valMul 
                                         , `Fundamentals` = corpFund)
                      )   
             )    
           )
           , plotOutput("chartAggr", height = 250)       


     )
    , column(6, style = "background-color:yellow;", div(style = "height:500px;")
    )
  ) 

)

亲切的问候

编辑 - 以下是答案:

试图在服务器端为renderPlot 的res 参数赋予更高的值似乎不起作用。例如,我给它的值是 128,并得到以下结果:

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    在服务器上的 renderPlot() 函数中,传入 res 参数...将其设置为高于默认的 72 像素/英寸。

    renderPlot(expr, width = "auto", height = "auto", res = 72, ..., env = parent.frame(), 引用 = FALSE, execOnResize = FALSE, outputArgs = list())

    请注意,您可能需要调整绘图的大小并向容器添加滚动条以适应更大的高分辨率图像。

    ## Something like this on the server
    output$barChart1 <- renderPlot(PLOT(), width = 1000, height = 1000, res = 128)
    
    ## Something like this on UI
    div(style = 'overflow-x: scroll', 
                       plotOutput("barChart1", inline = TRUE))
                    )
    

    【讨论】:

    • 感谢您的回答,我试过了,但结果是让图表变大了......但它并没有让我担心它变得不那么模糊:((见上文)。
    • 如果你看一下左上角的图像#2,它现在是高分辨率的,但被塞进了一个小容器中,这使它看起来很混乱,但不那么模糊。现在您可以在 renderPlot() 中使用宽度和高度参数,一定要添加一个滚动条,以便用户可以在通过小窗口显示的大图中移动高分辨率图像。
    【解决方案2】:

    我知道这是一篇旧帖子,但我想我会分享我的解决方案。

    我将绘图的高度按比例缩放到绘图的宽度,以便使用以下 renderPlot 代码修复纵横比:

      observeEvent({
        input$timelinecontinentselector
        input$timelinearrangeselector
        input$timelinesmoothselector == TRUE
      }, {
        output$timeline_plot <- renderPlot({
          timeline_plotting()
        }, height = function() {
          round(session$clientData$output_timeline_plot_width * 0.4)
        })
      })
    

    至关重要的是,最初没有 round() 函数。我只能假设表达式产生了一个带小数的高度值,这导致渲染器挣扎。将值四舍五入后问题就消失了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-30
      • 2015-01-19
      • 2015-12-06
      相关资源
      最近更新 更多