首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >R svgPanZoom自定义大小和添加定位器

R svgPanZoom自定义大小和添加定位器
EN

Stack Overflow用户
提问于 2016-10-02 14:02:14
回答 1查看 667关注 0票数 4

我目前正在开发一个漂亮的svgPanZoom软件包,我有两个问题还没有解决:

(1)可以动态定制图形的大小。我在代码之后尝试这样做(如在https://stackoverflow.com/questions/33522860/svgplot-error-in-shiny中):

代码语言:javascript
复制
library(shiny)
library(svglite)
library(svgPanZoom)
library(ggplot2)
library(plyr)

data.df <- data.frame(Plant = c("Plant1", "Plant1", "Plant1", "Plant2", "Plant2", 
                                "Plant2"), Type = c(1, 2, 3, 1, 2, 3), Axis1 = c(0.2, -0.4, 0.8, -0.2, -0.7, 
                                                                                 0.1), Axis2 = c(0.5, 0.3, -0.1, -0.3, -0.1, -0.8))

ui <- shinyUI(bootstrapPage(

  svgPanZoomOutput(outputId = "main_plot")

))

server = shinyServer(function(input, output) {
  output$main_plot <- renderSvgPanZoom({
    p <- ggplot(data.df, aes(x = Axis1, y = Axis2, shape = Plant, color = Type)) + geom_point(size = 5)
    svgPanZoom(p, controlIconsEnabled = T, width = 10, height = 16)
  })
})

runApp(list(ui=ui,server=server))

但什么也没发生:(你有什么主意吗?

(2),您知道是否可以在这段代码中包含一个定位器(如PlotOutput)

其主要思想是在一个正畸系统中绘制一幅(细胞的)图片,用户点击这张图片来定位细胞的细胞核。有时,图片上的单元格非常小,因此用户可能需要缩放(这就是我使用svgPanZoom的原因)。因此,我想得到的X和Y是整个正规化系统中的X和Y,即使用户使用缩放

我看了一下Cursor location after zoom using svg-pan-zoom,但似乎不是R

非常感谢你的想法!

祝你星期天晚上愉快!

Cha

EN

回答 1

Stack Overflow用户

发布于 2017-10-29 17:34:30

关于1):你的链接不再工作了。但是也许这个令人惊奇的shinyjqui包对你来说是有意义的。您可以在ui中添加jqui_resizabled()函数。在您的示例中是:jqui_resizabled(svgPanZoomOutput(outputId = "main_plot"))。你会在输出的左下角找到一个灰色的小符号。

请参阅一个小的gif示例(部分: resizable)和其他有趣的函数,这里是:https://github.com/Yang-Tang/shinyjqui

全文如下:

代码语言:javascript
复制
library(shiny)
library(svglite)
library(svgPanZoom)
library(ggplot2)
library(plyr)
library(shinyjqui)

data.df <- data.frame(Plant = c("Plant1", "Plant1", "Plant1", "Plant2", "Plant2", 
                                "Plant2"), Type = c(1, 2, 3, 1, 2, 3), Axis1 = c(0.2, -0.4, 0.8, -0.2, -0.7, 
                                                                                 0.1), Axis2 = c(0.5, 0.3, -0.1, -0.3, -0.1, -0.8))

ui <- shinyUI(bootstrapPage(

  jqui_resizabled(svgPanZoomOutput(outputId = "main_plot"))

))

server = shinyServer(function(input, output) {
  output$main_plot <- renderSvgPanZoom({
    p <- ggplot(data.df, aes(x = Axis1, y = Axis2, shape = Plant, color = Type)) + geom_point(size = 5)
    svgPanZoom(p, controlIconsEnabled = T, width = 10, height = 16)
  })
})

runApp(list(ui=ui,server=server))

我不太确定。人们可以尝试添加一个点击侦听器,但这将是一个相当丑陋的工作。也许smd知道更好的方法。

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

https://stackoverflow.com/questions/39817784

复制
相关文章

相似问题

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