gpt4 book ai didi

r - Shiny 图表空间分配

转载 作者:行者123 更新时间:2023-12-03 11:22:17 24 4
gpt4 key购买 nike

下面的示例在 4 个 Pane 中绘制了 4 个组。但问题是它们似乎驻留在一个网格中。是否可以控制 Shiny 输出中图表的大小? (即,当应用程序运行时,右侧没有滚动条)我试图控制高度和宽度,但这似乎只能控制网格本身内的图像......有什么想法吗?

谢谢

shinyUI(pageWithSidebar(
headerPanel("Example"),
sidebarPanel(

),

mainPanel(
tabsetPanel(tabPanel("Main",plotOutput("temp"))

)#tabsetPanel

)#mainPane;

))



shinyServer(function(input, output) {

output$temp <-renderPlot({
par(mfrow=c(2,2))
plot(1:10)
plot(rnorm(10))
plot(rnorm(10))
plot(rnorm(10))
}, height = 1000, width = 1000)


})

最佳答案

plotOutput也有高度和宽度参数;宽度默认为 "100%" (意味着其容器中可用宽度的 100%)并且高度默认为 "400px" (400 像素)。尝试使用这些值进行试验,将它们更改为 "auto""1000px" .
renderPlot的高度和宽度参数以像素为单位控制生成的图像文件的大小,但不直接影响网页中呈现的大小。它们的默认值都是 "auto" ,这意味着检测并使用对应 plotOutput 的宽度/高度.所以一旦你在 plotOutput 上设置了宽度和高度,一般不需要在renderPlot上设置宽高根本。

shinyUI(pageWithSidebar(
headerPanel("Example"),
sidebarPanel(

),

mainPanel(
tabsetPanel(tabPanel("Main",plotOutput("temp", height = 1000, width = 1000))

)#tabsetPanel

)#mainPane;

))



shinyServer(function(input, output) {

output$temp <-renderPlot({
par(mfrow=c(2,2))
plot(1:10)
plot(rnorm(10))
plot(rnorm(10))
plot(rnorm(10))
})


})

关于r - Shiny 图表空间分配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17204735/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com