r - 在闪亮的上下文中,高度参数不适用于 renderPlotly
问题描述
使用 ggplot,我可以创建我想要的情节。但是,当我转换为 plotly(下面的代码)时,出现错误:
Error in renderPlotly({ : unused argument (height = function() {
400 + (length(workforce_data()[["County.y"]]) * 5)
}).
我怎样才能解决这个问题?
情节代码
output$workforce_plot <- renderPlotly ({
workforce_plot()
} , height = function() {400 + (length(workforce_data()[["County.y"]]) *5) })
解决方案
renderPlotly
没有height
论据。
但是,您可以使用ggplotly
'height
参数,如下所示:
library(plotly)
library(shiny)
ui <- fluidPage(
sliderInput("heightSlider", "Plot heigth [px]", min = 200L, max = 1000L, value = 500L),
plotlyOutput("myPlot")
)
server <- function(input, output, session) {
output$myPlot <- renderPlotly({
p <- ggplot(data.frame(x = 1:10, y = runif(10)), aes(x, y)) + geom_point()
ggplotly(p, height = input$heightSlider)
})
}
shinyApp(ui, server)
推荐阅读
- vue.js - 每次请求后api不刷新
- javascript - 在响应中调用 'hasOwnProperty' (fetch-api)
- android - 在视图寻呼机中使用时的片段生命周期
- swift - 处理关闭和终止应用程序事件 (SwiftUI)
- jquery - 关于 Heroku 内容安全策略的 Express/MongoDB 应用程序从另一个域加载图像的问题(甚至是来自 cdn 的 jQuery ...)
- django - Postgres pgadmin4 错误:无法连接到服务器:docker 超时
- oracle - HTTP 303 甲骨文 ORDS
- twitter-bootstrap - 调整浏览器大小时,Bootstrap navbar-toggler-icon(3 栏堆栈)不显示
- powershell - 将结果从自定义 {0}`t{1}`t{2}`t{3}`t{4} 格式输出到 OGV?
- php - 尝试从发布请求访问请求属性以登录数据库 PHP Slim 3