简体   繁体   English

Plotly (ggplotly R) 滚动缩放,label 大小和工具提示选项

[英]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.我想知道如何通过滚动而不是使用缩放按钮将 plot 放大到特定区域,因为我需要动态探索不同分辨率的数据。 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.理想情况下,我会有类似谷歌地图 label 策略的东西,你只能看到高级别的主要标签,但是当你放大时,会显示更多标签。 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.一个与缩放相关的问题,当我使用 plot 文本标签时,它们的大小相对于呈现的 plot 区域保持不变,这意味着放大不会增加字体大小。 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.此外,工具提示配置不适用于以下策略,即在 ggplot 中将变量添加到 aes 并将它们的名称添加到 ggplotly 工具提示参数。

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?最后,当我 select 散点 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.我基本上是在寻找具有 select (通过框 select 或套索选项)特征识别特征并将它们导出以在另一个平台中进行分析,或者只是保存哪些合格。

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:您也可以使用 pipe 进行第二步:

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.我知识渊博,无法回答您的其他问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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