【发布时间】:2017-06-26 16:27:00
【问题描述】:
我正在尝试在闪亮的应用程序中调整 plotlyOutput 的大小,但在今天更新到 R 3.4 并更新闪亮和绘图后,更改高度参数似乎不会影响绘图大小(plotly_4.7.0,ggplot2_2.2.1.9000, shiny_1.0.3 )我意识到调整窗口大小时绘图的大小不会动态变化。我已经尝试直接使用 plotlyoutput 中的 height 修改绘图的大小,以及从 plotly 对象修改 $layout$height 属性,但它似乎对绘图的大小没有任何影响。 这是一个示例代码。
ui<-fluidPage(
mainPanel(
tabsetPanel(
tabPanel("tab",
selectInput("plot","Plot type",c("Box plot"="box","Inidividual cells"="cell","Violin plot"="violin"),"violin"),
plotlyOutput('Barplot',height = "100px")
)
)
)
)
server<- function(input,output,session){
output$Barplot <- renderPlotly({
bp <- ggplot(mtcars,aes(x=cyl,y=mpg,colour=cyl))+geom_point()
bp<-plotly_build(bp)
bp$layout$width= 100
bp
})
}
shinyApp(server=server,ui=ui)
【问题讨论】: