Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
394 views
in Technique[技术] by (71.8m points)

r - How to custom or display modebar in plotly?

I would like to custom the modebar (on top right) so as to keep just "zoom","pan","box select","zoom in" and "zoom out". If it's not possible, I prefer display the modebar.

Here graph and code : enter image description here

x <- c(1:15)
y <- c(1:15)
xy <- as.data.frame(cbind(x,y))
example <- ggplot(data = xy,aes(x = x,y = y))+geom_line()
ggplotly(example)

Thank you for help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Using your example:

x <- c(1:15)
y <- c(1:15)
xy <- as.data.frame(cbind(x,y))
example <- ggplot(data = xy,aes(x = x,y = y))+geom_line()

ggplotly(example) %>% config(displaylogo = FALSE,
modeBarButtonsToRemove = list(
    'sendDataToCloud',
    'toImage',
    'autoScale2d',
    'resetScale2d',
    'hoverClosestCartesian',
    'hoverCompareCartesian'
))

Example output

Other options include: 'zoom2d','pan2d','select2d','lasso2d','zoomIn2d', and 'zoomOut2d'


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...