相关疑难解决方法(0)

RStudio闪亮的情节的比例和大小

相关,但一般只讨论分配的绘图空间,而不是如何直接设置绘图图像大小然后缩放它以填充所需的空间


我正在创建一个闪亮的Web应用程序,并希望设置绘图比例的大小.我的意思是我正在寻找一种方法来为我的绘图设置有限的高度/宽度,然后将设置大小的图像缩放到该mainPanel( plotOutput ())区域.

以此作为例子/类似情况shiny.

x <- 1:10
y <- x^2
png("~/Desktop/small.png", width = 600, height = 400)
plot(x, y)
dev.off()

png("~/Desktop/big.png", width = 1200, height = 800)
plot(x, y)
dev.off()
Run Code Online (Sandbox Code Playgroud)

我无法将图像上传到SO并设置大小,因此我将使用以下html包含每个的浏览器屏幕截图:

<img src="file:///home/jwhendy/Desktop/file.png" width = "800px" />
Run Code Online (Sandbox Code Playgroud)

这是我1600 x 900 px笔记本电脑上的全宽屏幕截图.

小图片

更大的图片

我想控制图像本身的大小,因为我ggplot2在使用类似的选项时会发现这些图例colour = var并且size = var非常小.注意读取大图片的轴标签的难度.我意识到我可能会遇到由于像素有限而无法很好地缩放图像尺寸的情况,但我认为在遇到这种情况之前我至少有一些旅行空间.

有什么建议?到目前为止我试过玩下面的内容,但没有运气:

ui.R

shinyUI(pageWithSidebar(

headerPanel("Title"),

  sidebarPanel(),

  mainPanel(

     plotOutput(outputId = "main_plot", width = "100%")) …
Run Code Online (Sandbox Code Playgroud)

size r rstudio shiny

53
推荐指数
2
解决办法
8万
查看次数

在R闪亮页面中显示/隐藏侧边栏后,Plot不会调整100%宽度

我有一个在R Shiny的双面板页面的主面板中设置为100%宽度(默认)的绘图.侧边栏可通过切换操作按钮隐藏.

当侧边栏可见(默认)时,绘图将填充主面板的宽度.当侧边栏被隐藏时,我希望绘图扩展以填充现有空间的100%,即整个浏览器窗口.但这不会发生!它保持相同的大小.

library(shiny)
library(shinyBS)

UI <- fluidPage(
    bsButton("showpanel", "Show/hide sidebar", type = "toggle", value = TRUE),
    sidebarLayout(
        conditionalPanel(condition = "input.showpanel == true",
                         sidebarPanel("This is my sidebar.")
                         ),
        mainPanel(plotOutput("plot", width = "100%"))
        )
    )

SERVER <- function(input, output) {
        output$plot <- renderPlot({
        plot(1:10, main = "The width of this plot adjusts\nto window resizes but not to\nshow/hide sidepanel!")
    })
}

runApp(shinyApp(UI,SERVER))
Run Code Online (Sandbox Code Playgroud)

到目前为止尝试:

  • 如上所述,在UI文件中定义绘图对象.
  • 从服务器文件中定义绘图对象,作为renderUI对象.
  • tags$head(tags$style("#myplot{height:100vh !important;}"))根据此问题在页面中设置CSS标记,将闪亮的图形缩放到窗口高度.

可能的解决方法:

  • 使绘图的宽度动态化,具体取决于切换按钮的状态.然后,当侧边栏被隐藏时,我可以使绘图例如140%宽度.这并没有很好地概括,并且失去了使用适应性的观点fluidPage.

(fluidPage根据浏览器窗口大小更改布局.例如,如果您使浏览器窗口大小与手机大小相同,则会将侧边栏放在主面板上方.)

css r shiny

16
推荐指数
2
解决办法
1444
查看次数

如何在没有工具栏的情况下显示我的情节?

这个问题的扩展这个问题.

我正在Shiny中绘制一个相当大的gglot.

使用renderPlot(width = 1500, height = 1000, ...我能够显示整个情节; 但是,我现在右边有一个滚动条.我想在fluidRow中扩展列的高度,而不是使用此滚动条.

在此输入图像描述

根据我的理解,Shiny(也称为bootstrap)应该动态调整fluidRow的高度,使其与绘图的大小无关.为什么我的可见区域这么小?滚动条很不错,但我希望整个情节都可见.

UI.R

source("helper.R")    
shinyUI(fluidPage(theme='test.css',

    fluidRow(
    column(2, 
           fluidRow(
             h3("Select Customer:"),
                    wellPanel(class="info", numericInput(inputId="num", label="Select ID:", value=NaN),
                              if(show_age_slider=='Yes'){textOutput("")},
                              if(show_edu_slider=='Yes'){textOutput("")},
                              if(show_gender_buttons=='Yes'){textOutput("")}
                    ))),

    #do.call will call the navbarPage function with the arguments in the tabs list
    shinyUI(fluidRow(
      column(12,
             "", 
             do.call(navbarPage,tabs)
    ))))))
Run Code Online (Sandbox Code Playgroud)

SERVER.R

library("shiny")
library("ggplot2")

DF_for_plotting <- structure(list(col1 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0), col2 = c(100, 
                                                                                   100, 61.9433678425096, 10.7823906941804, 4.18175346165306, 3.24251454697229, 
                                                                                   6.68573373055455, 14.945119260922, 18.9296271776082, 11.0742379220636
), …
Run Code Online (Sandbox Code Playgroud)

html css r shiny twitter-bootstrap-3

6
推荐指数
1
解决办法
549
查看次数

Shinydashboard Tabbox 高度

我正在尝试创建一个tabBox跨越整个mainPanel. 我能够获得跨越整个屏幕的宽度,但我无法获得高度来做同样的事情。我不希望以像素(或其他一些单位)为单位使用绝对值,因为我希望该应用程序可以在不同的屏幕上使用。

我玩了这个例子,修改的例子tabBox如下

fluidRow(
        tabBox(
            title = "First tabBox",
            # The id lets us use input$tabset1 on the server to find the current tab
            id = "tabset1", height = "450px",
            tabPanel("Tab1", "First tab content"),
            tabPanel("Tab2", "Tab content 2"),
            width = 12
        ),
        height = '20%',
        width = 12
    )
Run Code Online (Sandbox Code Playgroud)

css r shiny shinydashboard

4
推荐指数
1
解决办法
3214
查看次数

标签 统计

r ×4

shiny ×4

css ×3

html ×1

rstudio ×1

shinydashboard ×1

size ×1

twitter-bootstrap-3 ×1