调整plotlyOutput对象的大小 [英] Resizing plotlyOutput object
问题描述
我正在尝试在闪亮的应用程序中调整plotlyOutput的大小,但在将当前值更新为R 3.4并更新闪亮后,plotly(plotly_4.7.0,ggplot2_2.2.1.9000, Shiny_1.0.3)我意识到,调整窗口大小时,图的大小不会动态更改.我试过直接使用plotlyoutput中的height修改图的大小,以及修改plotly对象的$ layout $ height属性,但它似乎对图的大小没有任何影响. 这是示例代码.
I am trying to resize a plotlyOutput in a shiny app but changing the height parameters doesnt seem to affect the plot size, after updating today to R 3.4 and updating shiny, and plotly (plotly_4.7.0, ggplot2_2.2.1.9000, shiny_1.0.3 ) I realized that the size of the plot does not change dynamically when resizing the window. I have tried modifying the size of the plot directly using height in plotlyoutput, as well as modifying the $layout$height property from the plotly object,t but it doesnt seem to have any effect on the size of the plots. Here is a sample code.
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)
推荐答案
尝试
plotlyOutput('Barplot')
和
bp <- ggplot(mtcars,aes(x=cyl,y=mpg,colour=cyl))+geom_point()
ggplotly(bp, height=800) %>% layout(autosize=FALSE)
这篇关于调整plotlyOutput对象的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!