首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ggplotly工具提示反复无常

ggplotly工具提示反复无常
EN

Stack Overflow用户
提问于 2019-04-02 00:37:32
回答 1查看 138关注 0票数 0

我有这个NBA球场的ggplotly对象,显示了每个球员的投篮次数。正如你所看到的,当我将鼠标悬停在球场的每个区域上时,我看到工具提示的行为非常不可预测。我感觉是这样的,因为法庭是用geom_polygongeom_path制作的。代码见下文:

数据(gg_lineup_fga):http://www.filedropper.com/gglineupfga

代码语言:javascript
复制
rank_colors <- RColorBrewer::brewer.pal(5, "RdYlBu")

ggplot2::ggplot(data = gg_lineup_fga, ggplot2::aes(x=long, 
                                                                y=lat, 
                                                                group = group,
                                                                fill = rank,
                                                                text = paste0("FGA : ", round(fga, 2)))) +
  ggplot2::facet_grid(. ~ player) +
  ggplot2::geom_polygon()  +
  ggplot2::geom_path(color = "black")  +
  ggplot2::coord_equal() +
  ggplot2::scale_fill_manual(values = rank_colors,
                             limits = 1:5,
                             name = NULL) +
  ggplot2::theme(axis.line=ggplot2::element_blank(),
                 axis.text.x=ggplot2::element_blank(),
                 axis.text.y=ggplot2::element_blank(),
                 axis.ticks=ggplot2::element_blank(),
                 axis.title.x=ggplot2::element_blank(),
                 axis.title.y=ggplot2::element_blank(),
                 panel.background=ggplot2::element_blank(),
                 panel.border=ggplot2::element_blank(),
                 panel.grid.major=ggplot2::element_blank(),
                 panel.grid.minor=ggplot2::element_blank(),
                 strip.text = ggplot2::element_text(size = 16), 
                 strip.background = ggplot2::element_blank(),
                 legend.position = "none",
                 # legend.margin = ggplot2::margin(0.1, 0.1, 0.1, 0, "npc"),
                 plot.margin = ggplot2::unit(c(0, 0, 0, 0), "cm"),
                 panel.spacing.y = ggplot2::unit(0, "cm"),
                 text=element_text(size=16, family="Avenir"))

为了解决这个问题,我可以去掉geom_path,但这会删除法院区域的黑线边界。我想知道plotly中是否有参数阻止工具提示与geom_path交互(仅与geom_polygon交互)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-02 03:10:51

移除geom_path并将颜色添加到geom_polygon以对边界进行着色,即geom_polygon(color ='black')

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55459802

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档