Open nspyrison opened 2 years ago
Order of geoms effects the issue:
require(ggplot2)
#> Loading required package: ggplot2
require(plotly)
#> Loading required package: plotly
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
df_txt <- data.frame(x=1, y=1, label="No tooltip here, please", frame = 1:2)
df_pts <- data.frame(x=rep(c(1, 1), each=2), y=c(.9, .95, .8, .85),
tooltip=paste("obs_num: ", 1:2, "tooltip exclusively for points with different dim"),
frame = rep(1:2, each=2))
## frame1: points, frame2: points
g_pt1st <- ggplot() +
geom_point(aes(x,y, tooltip=tooltip, frame=frame), df_pts) +
geom_text(aes(x,y, label=label, frame=frame), df_txt)
#> Warning: Ignoring unknown aesthetics: tooltip, frame
#> Warning: Ignoring unknown aesthetics: frame
plotly::ggplotly(g_pt1st, tooltip = "tooltip")
## frame1: points, frame2: text
g_txt1st <- ggplot() +
geom_text(aes(x,y, label=label, frame=frame), df_txt) +
geom_point(aes(x,y, tooltip=tooltip, frame=frame), df_pts)
#> Warning: Ignoring unknown aesthetics: frame
#> Warning: Ignoring unknown aesthetics: tooltip, frame
plotly::ggplotly(g_txt1st, tooltip = "tooltip")
Created on 2021-10-30 by the reprex package (v2.0.1)
Using ids=id inside of aes() does not help.
## Adding aes(`ids`) doesn't seem to help
library(ggplot2)
library(plotly)
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
df_txt <- data.frame(x=1, y=1, label="No tooltip here, please", frame = 1:2, id = 1)
df_pts <- data.frame(x=rep(c(1, 1), each=2), y=c(.9, .95, .8, .85),
tooltip=paste("obs_num: ", 1:2, "tooltip exclusively for points with different dim"),
frame = rep(1:2, each=2),
id = rep(2:3, 2))
## animation, aes has frame AND ids
g_anim2 <- ggplot() +
geom_text(aes(x,y, label=label, frame = frame, ids=id), df_txt) +
geom_point(aes(x,y, tooltip=tooltip, frame = frame, ids=id), df_pts)
#> Warning: Ignoring unknown aesthetics: frame, ids
#> Warning: Ignoring unknown aesthetics: tooltip, frame, ids
plotly::ggplotly(g_anim2, tooltip = "tooltip")
Created on 2021-10-30 by the reprex package (v2.0.1)
1) Cannot stop geom_text from displaying tooltip. 2) Animations will not display all geoms on all frames (note that data has differing rownumers
Created on 2021-10-28 by the reprex package (v2.0.1)