我正在尝试调整闪亮的plotOutput
ui对象的大小
library(shiny)
ui <- fluidPage(
fluidRow(
column(6, numericInput('save.height', "Save height (mm)", value = 50)),
column(6, numericInput('save.width', "Save width (mm)", value = 43))),
plotOutput('plot_display', width = '50mm', height = '43mm'))
server <- function(input, output) {
output$plot_display <- renderPlot({
ggplot(iris, aes(x = Species, y = Petal.Length)) +
stat_summary(geom = 'bar', fun.y = mean) +
geom_point() +
theme(aspect.ratio = 1)
})
}
shinyApp(ui, server)
我无法找到与updateNumericInput()
等效的东西来动态更新plotOutput
中的值
答案 0 :(得分:4)
您还可以使用很棒的shinyjqui
软件包:
library(shiny)
library(shinyjqui)
shinyApp(
ui = fluidPage(
jqui_resizabled(plotOutput('hist'))
),
server = function(input, output) {
output$hist <- renderPlot({
hist(rnorm(100))
})
}
)
答案 1 :(得分:3)
为此,您必须指出输出的大小取决于输入的值。您可以在下面找到一个有效的示例:
library(shiny)
library(ggplot2)
ui <- fluidPage(
fluidRow(
column(6, numericInput('save.height', "Save height (mm)", value = 500)),
column(6, numericInput('save.width', "Save width (mm)", value = 450))),
plotOutput('plot_display'))
server <- function(input, output) {
output$plot_display <- renderPlot({
ggplot(iris, aes(x = Species, y = Petal.Length)) +
stat_summary(geom = 'bar', fun.y = mean) +
geom_point()
},height = function()input$save.height, width = function()input$save.width)}
shinyApp(ui, server)