我正在尝试使用ggplotly
与一些geom_ribbon
进行交互式绘图。
图看起来像(使用tidyverse
包制作的数据):
temp_data <-
tibble(Group = 1, x = 1) %>%
complete(Group = 1:3, x = 1:10) %>%
mutate(y_val = x + Group * 5
, ymin = y_val - 3/Group
, ymax = y_val + 3/Group)
temp_plot <-
ggplot(temp_data
, aes(x = x
, ymin = ymin
, ymax = ymax
, fill = Group
, group = Group)) +
geom_ribbon()
情节如下:
我想要哪个情节。但是,当我使用plotly
在ggplot(temp_plot)
中进行渲染时,出现错误:
eval(substitute(expr),data,enclos = parent.frame())错误:
找不到“ tickvals”对象
我可以追踪到geom_ribbon
元素,尤其是图例。如果我运行ggplotly(temp_plot + theme(legend.position = "none"))
,则绘图可以正常渲染(没有图例)。
我正在运行ggplot2
(ggplot2_3.2.0.9000)和plotly
(plotly_4.9.0)的最新稳定版本。值得注意的是,在运行旧版本ggplot2(ggplot2_3.1.1)的服务器上,我确实未得到此错误,但是该服务器是plotly
上的最新版本。