简体   繁体   中英

Plotly (ggplotly R) Scroll zoom, label size and tooltip options

I was wondering how can I enable zooming into the plot by scrolling rather than using the zoom button to select a specific area since I need a dynamic exploration of the data at different resolutions. Ideally, I would have something like google maps label strategy where you see only major labels in high level, but as you zoom in more labels are being shown. An issue related to zoom, when I plot textual labels, their size remain relative to the presented plot area, meaning that zooming in doesn't increase the font size. is there a way to make the font size appear bigger upon zoom? 初始视图 and after zoom showing labels size is smaller飞涨 Also, the tooltip configuration doesn't work for me with the following strategy of adding the variables to aes in ggplot and adding their names to ggplotly tooltip parameter.

p <- ggplot(mtcars, aes(x = disp, y= am, color = as.factor(cyl), 
                        gear=gear, hp=hp))+geom_point()
ggplotly(p,tooltip = c("x", "gear", "hp"))

Finally, is there any possibility to have a list of labels appear on the right as text when I select a bunch of points on that scatter plot? I'm basically looking to identify features with select (by the box select or lasso option) characteristics and export them for analysis in another platform, or just save which ones qualified.

Thank you

You can switch on zooming by mouse scrolling like this:

library(plotly)
p <- ggplot(mtcars, aes(x = disp, y= am, color = as.factor(cyl),
                        gear=gear, hp=hp)) + geom_point()
q <- ggplotly(p, dynamicTicks = TRUE)
config(q, scrollZoom = TRUE)

You can also use a pipe for the second step:

library(plotly)
p <- ggplot(mtcars, aes(x = disp, y= am, color = as.factor(cyl),
                        gear=gear, hp=hp)) + geom_point()
ggplotly(p) %>% config(scrollZoom = TRUE)

I am not knowleadgable enough to answer your other questions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM