相关疑难解决方法(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万
查看次数

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

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

我正在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
查看次数

如何在闪亮的上下文中更改绘图的高度

如下图所示,当在侧栏中选择多个县时,我的图的高度保持不变。这使得情节过于拥挤,以至于标签变得不可读。我想根据侧栏中选择的县数来改变我的情节的高度。我怎样才能做到这一点?

下面,请查看我认为需要修改的部分代码。

在此处输入图片说明

界面元素

mainPanel(plotOutput("workforce_plot"), 
Run Code Online (Sandbox Code Playgroud)

服务器元素

workforce_plot <- reactive({
     ggplot(workforce_data(), aes(x =Age_Group, y = Percentage, fill=County.y)) + 
     geom_bar(stat = "identity",position = position_dodge()) +                                                         
     geom_text(
     aes(label = Percentage2),
     vjust = 0.5,
     colour = "black", 
     position = position_dodge(width=0.9),
     fontface = "bold",
     size=3.2,
     hjust = 0)+
     ylim(0,110)+        
     coord_flip()+

     labs(
          x = "Age Groups",
          y = "Percentage",
          face = "bold")
          })

   output$workforce_plot <- renderPlot ({ 
            workforce_plot()
          })
Run Code Online (Sandbox Code Playgroud)

r shiny

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

标签 统计

r ×3

shiny ×3

css ×1

html ×1

rstudio ×1

size ×1

twitter-bootstrap-3 ×1