r - 在 Shiny 的 mainPanel 和 sideerbarPanel 之间添加空间

标签 r ggplot2 shiny plotly

在下面的 Shiny 应用程序中,我想在 mainPanel 和底部的 siderbarPanel 之间添加一些空格。 enter image description here

在这里,我无法读取 x 轴刻度,我尝试旋转它们,但它并没有改善问题。 我还更改了plotlyOutput的高度和宽度,但不起作用。 我尝试添加 HTML("<br><br><br>")但也不起作用,问题可能来自 ggplot 或plotly ?

我的 ggplot 脚本是:

  ggplot(data = df, aes(x = perimetre_commercial_estime,
                        y = nbr_ligne, 
                        fill = perimetre_commercial_estime)) +
    geom_bar(stat="identity") + theme_light() + 
    theme(axis.text.x=element_text(angle=30,hjust=1,vjust=0.5,size=6),
                                      axis.title.x=element_blank(),
          legend.position="top", legend.direction="horizontal") +
    scale_fill_discrete("") 

plotly不支持水平图例,所以下图是正常的。

谢谢

最佳答案

这个Plotly Setting Graph Size in R文章可能会有所帮助。由于您没有包含所有代码,我无法完全确认。请告诉我。

library(plotly)
library(dplyr)

gp = ggplot(
  data = mtcars %>% add_rownames(),
  aes( x = rowname, y = mpg )
) + geom_point() +
  theme(axis.text.x=element_text(angle=30,hjust=1,vjust=0.5,size=6),
        axis.title.x=element_blank())

ggplotly(gp) %>%
  layout(
    margin = list(
      b=100
    )
  )

关于r - 在 Shiny 的 mainPanel 和 sideerbarPanel 之间添加空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37298853/

相关文章:

r - 具有交互式 x 和 y 的 Shiny ggplot 不会将信息传递给画笔

r - 如何最好地将 data.table 的一列与同一 data.table 的另一列连接起来?

r - R中igraph中顶点属性的导入

r - 在 ggplot2 中结合 position_dodge 和 position_fill

r - 无法过滤数据框?

R-ggplot : Selection of which labels to appear in bar stack and their position

r - 如何使用 FactoMineR 创建双标图?

mysql - 如何使用池连接来连接表?

r - Shiny 的 : How to modify reactive object

r - 根据两个字符列之间的差异创建 R data.frame 列