subplot() not producing the interactive equivalent of gridExtra::grid.arrange()
未关闭
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
Given:
library(ggplot2)
library(gridExtra)
library(plotly)
library(colorRamps)
d <- data.frame(x=sample(1:10)/10, y=sample(1:10)/10, z=sample(1:10)/10, c=sample(LETTERS[1:5],size=10,replace=TRUE))
g1 <- ggplot(d) +
geom_point(aes(x=x, y=y, fill = z),
pch=21,size=4) +
facet_wrap(~c,labeller = label_both) +
scale_fill_gradientn(colors = matlab.like2(16),limits=c(0, 100)) +
xlim(c(0,1)) + ylim(c(0,1)) +
coord_fixed(ratio = 1) +
theme(legend.position=c(0.85,0.2), legend.background=element_blank()) +
labs(fill = "%")
g2<- g1+ggtitle("Plot 2")
g3<- g1+gtitle("Plot 3")
g4<- g1+ggtitle("Plot 4")
g1<- g1+ggtitle("Plot 1")
p = list(g1,g2,g3,g4) %>% map(~.x + labs(x=NULL, y=NULL))
yleft= "X"
xbottom= "Y"
grid.arrange(grobs=p,bottom = xbottom, left = yleft,nrow=2)
I want to get the same plot but with interactive browsing of the values. I try:
pg1 <- ggplotly(g1)
pg2 <- ggplotly(g2)
pg3 <- ggplotly(g3)
pg4 <- ggplotly(g4)
Individual plots are ok:
pg1
But
subplot(list(pg1, pg2,pg3,pg4), nrows=2,
shareX=FALSE, shareY=FALSE,titleX=TRUE,titleY=TRUE)
or
subplot(list(pg1, pg2,pg3,pg4), nrows=2,
shareX=FALSE, shareY=FALSE,titleX=FALSE,titleY=FALSE)
result into:
Which is almost good but displays only 1 title (and in the wrong place) and no axes titles.
I try
subplot(list(pg1, pg2,pg3,pg4), nrows=2,
shareX=TRUE, shareY=TRUE,titleX=FALSE,titleY=FALSE)
and
subplot(list(pg1, pg2,pg3,pg4), nrows=2,
shareX=TRUE, shareY=TRUE,titleX=TRUE,titleY=TRUE)
and the result is even worse:
Is this a bug or am I doing something wrong? Is there an alternative way to get the interactive version of the grid?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 issue 中复现的 ggplotly() 和 subplot() 调用开始,将它们的输出与 grid.arrange() 进行比较。跟踪 subplot() 如何处理多个图表标题、共享坐标轴和坐标轴标题。完成的标准是:四个转换后的图表在两行的交互式布局中保留预期的标题和坐标轴,或者将该行为记录为一项限制。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100