“geom_dotplot_interactive() 移除点的堆叠。”

huangapple go评论67阅读模式
英文:

geom_dotplot_interactive() removes stacking of points

问题

geom_dotplot_interactive() 允许使用 ggiraph 包创建一个交互式的点图。

library(dplyr)
library(ggplot2)
library(ggiraph)
p <- iris %>%
  ggplot(aes(x = Sepal.Length)) +
  geom_dotplot_interactive()
girafe(ggobj = p)

然而,一旦我尝试添加工具提示,点就不再堆叠。

p <- iris %>%
  mutate(rn = as.character(row_number())) %>%
  ggplot(aes(x = Sepal.Length)) +
  geom_dotplot_interactive(aes(tooltip = rn))
girafe(ggobj = p)

“geom_dotplot_interactive() 移除点的堆叠。”

英文:

geom_dotplot_interactive() allows to create an interactive dotplot with the package ggiraph

library(dplyr)
library(ggplot2)
library(ggiraph)
p &lt;- iris %&gt;%
  ggplot(aes(x = Sepal.Length)) +
  geom_dotplot_interactive()
girafe(ggobj = p)

“geom_dotplot_interactive() 移除点的堆叠。”

However, as soon as I try to add a tooltip, the points no longer stack.

p &lt;- iris %&gt;%
  mutate(rn = as.character(row_number())) %&gt;% 
  ggplot(aes(x = Sepal.Length)) +
  geom_dotplot_interactive(aes(tooltip = rn))
girafe(ggobj = p)

“geom_dotplot_interactive() 移除点的堆叠。”

答案1

得分: 1

Tooltip引入了一种新的分组方式(?), 这使得需要更改geom_dotplot_interactive的一些默认参数以获得相同的结果。具体来说,确定跨组的binpositions和跨组的stack:

p <- iris %>%
  mutate(rn = as.character(row_number())) %>%
  ggplot(aes(x = Sepal.Length)) +
  geom_dotplot_interactive(aes(tooltip = rn), binpositions = "all", stackgroups = TRUE)
girafe(ggobj = p)

“geom_dotplot_interactive() 移除点的堆叠。”

英文:

Tooltip introduces a new grouping(?), which makes it necessary to change some of the default arguments of geom_dotplot_interactive to get the same result. Namely, determine binpositions across groups and stack across groups:

p &lt;- iris %&gt;%
  mutate(rn = as.character(row_number())) %&gt;% 
  ggplot(aes(x = Sepal.Length)) +
  geom_dotplot_interactive(aes(tooltip = rn), binpositions = &quot;all&quot;, stackgroups = TRUE)
girafe(ggobj = p)

“geom_dotplot_interactive() 移除点的堆叠。”

huangapple
  • 本文由 发表于 2023年7月7日 00:27:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/76630837.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定