我想为
此外,我想知道如何增加subplot中图表之间的边距,因为它们看起来非常挤在一起。
任何帮助都将不胜感激!
plotly
的subplot
函数中的每个图表提供单独的标题。我找到了一篇文章,其中介绍了如何使用%>% layout(title = "Main Title)
扩展subplot,但我想为每个图表提供单独的标题(我正在使用ggtitle
,但它只会绘制最后一个提供的标题(Plot 4)。我发现了一篇类似的文章Provide title to each of the subplots - R Shiny,但我不认为在我的情况下可以使用facet_wrap
。此外,我想知道如何增加subplot中图表之间的边距,因为它们看起来非常挤在一起。
任何帮助都将不胜感激!
ui <- fluidPage(
sidebarPanel("This is a sidebar"),
mainPanel(plotlyOutput("myplot"))
)
server <- function(input, output){
output$myplot <- renderPlotly({
gg1 <- ggplotly(
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width)) +
geom_point() +
theme_minimal() +
ggtitle("Plot 1")
)
gg2 <- ggplotly(
ggplot(iris, aes(x=Species, y=Sepal.Length)) +
geom_boxplot() +
theme_minimal() +
ggtitle("Plot 2")
)
gg3 <- ggplotly(
ggplot(iris, aes(x=Petal.Width)) +
geom_histogram() +
ggtitle("Plot 3")
)
gg4 <- ggplotly(
ggplot(iris, aes(x=Petal.Length)) +
geom_histogram() +
ggtitle("Plot 4")
)
subplot(list(gg1,gg2,gg3,gg4), nrows = 2)
})
}
shinyApp(ui = ui, server = server)
annotation
来完成一些工作..你需要将所有4个图保持在一起吗? - Edo