[英]ggiraph error when using coord_polar() and geom_segment_interactive
我正在制作一张全年动物发生率的圆形图。 我有许多变量(环)以及到达和离开日期。 我正在尝试使用 shiny 和 ggiraph 向我的图表添加更多交互功能。
在 ggiraph 中,我使用 geom_segment_interactive 和 coord_polar()。 在我添加 coord_polar() 之前一切正常。
使用 ggiraph geom_segment_interative示例的问题示例。
dataset = data.frame(x=c(1,2,5,6,8),
y=c(3,6,2,8,7),
vx=c(1,1.5,0.8,0.5,1.3),
vy=c(0.2,1.3,1.7,0.8,1.4),
labs = paste0("Lab", 1:5))
dataset$clickjs = paste0("alert(\"",dataset$labs, "\")" )
gg_segment_2 = ggplot() +
geom_segment_interactive(data=dataset, mapping=aes(x=x, y=y,
xend=x+vx, yend=y+vy, tooltip = labs, onclick=clickjs ),
arrow=grid::arrow(length = grid::unit(0.03, "npc")),
size=2, color="blue") +
geom_point(data=dataset, mapping=aes(x=x, y=y),
size=4, shape=21, fill="white")
x <- girafe(ggobj = gg_segment_2)
if( interactive() ) print(x)
所有这些都很好。 如果我们将 coord_polar() 添加到 ggplot 代码中,它会引发错误。
gg_segment_2 = ggplot() +
geom_segment_interactive(data=dataset,
mapping=aes(x=x, y=y, xend=x+vx, yend=y+vy, tooltip = labs, onclick=clickjs ),
arrow=grid::arrow(length = grid::unit(0.03, "npc")),
size=2, color="blue") +
geom_point(data=dataset, mapping=aes(x=x, y=y),
size=4, shape=21, fill="white")+
coord_polar()
x <- girafe(ggobj = gg_segment_2)
if( interactive() ) print(x)
stop_subscript()
中的错误:。 无法重命名不存在的列。 x 列x
不存在。 运行rlang::last_error()
以查看错误发生的位置。
如果我将 geom_segment_interactive 更改为 geom_segment 并运行代码,无论有无 coord_polar() 它都可以工作。 任何关于我所缺少的建议将不胜感激。
我想使用交互式版本,所以当我在我的 shiny 应用程序中使用我的真实数据集时,我可以 select 不同的物种出现在圆形图中,而且还能够使用工具提示来识别不同的物种。
这是一个错误,现在已在最新的 github 版本中修复(很快就会出现)。
使用devtools::install_github('davidgohel/ggiraph')
安装它。
请将您可能遇到的任何问题提交给https://github.com/davidgohel/ggiraph/issues
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.