ggplotly arrows not functioning
未关闭
还没有人认领这个 Issue。
ggplotly
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
Build a data.frame
tempDf <- data.frame("x" = c(22.1, 22.1, 14.4, 32.1, 22.0, 32.1, 84.3, 15.9, 15.9, 11.8, 11.8, 25.1, 15.7, 22.4, 35.1, 36.6, 70.4, 65.2, 42.9, 36.3, 47.8),
"y" = c(21.0, 21.0, 39.8, 47.6, 69.6, 95.0, 94.8, 17.3, 17.3, 27.6, 27.6, 90.3, 85.7, 94.1, 72.3, 71.5, 100.0, 92.4, 76.9, 34.6, 4.9),
"endX" = c(NA, 13.1, 31.9, 22.0, 29.7, 84.3, 94.4, NA, 15.1, NA, 25.0, 14.3, 22.4, 59.6, NA, 70.4, 65.9, 44.2, 38.3, 48.3, 72.1),
"endY" = c(NA, 33.3, 46.0, 69.6, 93.5, 94.8, 51.6, NA, 22.1, NA, 90.3, 85.4, 94.1, 96.8, NA, 100.0, 91.5, 80.8, 37.1, 5.2, 36.9),
"index" = c(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0),
"string"= c(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0) )
Make plot using ggplot.
ggplot(tempDf, aes(x=x, y=y)) + geom_point(size = 4, shape = 0, aes(fill="green")) +
geom_text(aes(label= string), size = 2) +
geom_segment(data = tempDf, aes(x=x, xend=endX, y=y, yend=endY, group = index, color=as.factor(index)), size = .3, arrow=arrow(length=unit(0.3,"cm")) ) + xlim(0,100) + ylim(0,100) +
theme(panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
panel.background = element_rect(fill = "grey90"),
axis.ticks.x = element_blank(),
axis.ticks.y = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
#legend.title=element_blank(),
#legend.margin=unit(-.4, "cm"),
plot.margin=unit(c(0, 0, 1.3, -1), units="cm"), #top, right, bottom, left
legend.text = element_text(size = 14, face = "bold") ) +
xlab("") + ylab("")
Makes a plot that looks like this.

Turn it into a plotly plot in and drop it in a shiny app (literally the same code with a 'ggplotly' tacked on)
And this is the output.
No arrows.
In addition, in the original plot I can do both a geom_point() with a empty square and a geom_text() and get the numerals to appear inside the square. That's also not appearing here. That is technically a separate issue. If you like I can open up another thread for that issue.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行提供的 ggplot 示例,然后在 Shiny 应用中将同一个图传递给 ggplotly,并比较渲染后的输出。重点关注报告中描述的 geom_segment 箭头以及 geom_point 与 geom_text 的组合。当箭头在交互式图中正确渲染,且点标签按预期显示时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100