[英]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.