如何从 ggplotly 图中删除选项栏? [英] How to remove option bar from ggplotly plot?

查看:23
本文介绍了如何从 ggplotly 图中删除选项栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 plotlyggplot2shiny 中渲染的绘图.但是,我不希望出现悬停时出现的选项栏.有没有办法使用 ggplotly(p) 并删除选项栏?

I have a plot that I am rendering in shiny using plotly and ggplot2. However, I do not want the option bar that appears on hover to appear. Is there a way to use ggplotly(p) and remove the option bar?

推荐答案

community plotly 简短版:

library(plotly)
set.seed(100)
d <- diamonds[sample(nrow(diamonds), 1000), ]

使用ggplotly:

p <- ggplot(d, aes(carat, price)) + geom_point()
ggplotly(p) %>% config(displayModeBar = F)

如果你不使用 ggplotly 你可以这样做:

If you are not using ggplotly you can do:

plot_ly(d, x = carat, y = price, text = paste("Clarity: ", clarity),
mode = "markers", color = carat, size = carat) %>% config(displayModeBar = F)

这篇关于如何从 ggplotly 图中删除选项栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆