标签: ggiraph

如何在 R 中 ggiraph 包的工具提示 cloude 中添加更多信息?

我想创建一个云,它使用 ggiraph 包中的工具提示显示有关该点的信息。我可以创建一个只有一个信息(来自一列)的云,但我想添加来自三列的信息。下面我添加了一张我想要实现的图片和代码。代码是正确的,但图中只有一列的信息。

图片显示了我想要实现的目标

#lib.
library(ggiraph)
library(ggplot2)
library(shiny)

#create data frame
col_A=c(123,523,134,543,154)
col_B=c(100,200,300,400,500)
col_C=as.character(c("food_1", "food_2", "food_3", "food_4", "food_5"))
df=data.frame(col_A, col_B, col_C)
df$col_C <- as.character(df$col_C)


#ui.
ui <- fluidPage(    
  ggiraph::ggiraphOutput("plot1"))



#server
server <- function(input, output) {

  gg <- ggplot(data = df ,aes(x = col_A, y = col_B)) + 
geom_point_interactive(tooltip=df$col_C)
  # I would like to plot like this: geom_point_interactive(tooltip=c(df$col_A, df$col_B, df$col_C))
  # but i causes error: Aesthetics must be either length 1 or the same as the data (5): tooltip

  output$plot1 <- …
Run Code Online (Sandbox Code Playgroud)

r tooltip shiny ggiraph

5
推荐指数
1
解决办法
822
查看次数

ggiraph 图不会调整大小以适合页面

这是我的代码:

library(shiny)
library(ggplot2)
library(ggiraph)

df <- data.frame(achseX = LETTERS[1:24], achseY = 1:24, facetX = as.factor(rep(1:4, each = 6)))

server <- function(input, output) {
  output$ggplot <- renderPlot({
    ggplot(data = df) + geom_bar_interactive(aes(tooltip = achseY, x = achseX, y = achseY), stat = "identity") +
      theme_minimal() + facet_grid(.~ facetX, scales = "free_x")
  })


  output$plot <- renderggiraph({
    gg <- ggplot(data = df) + geom_bar_interactive(aes(tooltip = achseY, x = achseX, y = achseY), stat = "identity") +
      theme_minimal() + facet_grid(.~ facetX, scales = "free_x") …
Run Code Online (Sandbox Code Playgroud)

r ggplot2 shiny ggiraph

5
推荐指数
2
解决办法
2445
查看次数

ggiraph 图没有出现在闪亮的应用程序中,但在 RStudio 中有效

我真的很想用来ggiraph在我的shiny应用程序中添加工具提示。但是,当我尝试这样做时,情节不会出现。在下面的示例中,我使用了plotOutputandggiraphOutput但只my.plot出现了。我可以在 RStudio 中生成交互式绘图,而不是在应用程序中。我的实现有问题吗?或者可能存在兼容性问题(sessionInfo()如下)?谢谢!

library(ggiraph)
library(shiny)
library(ggplot2)
ui <- fluidPage(
  fluidRow(
    column(6,plotOutput(outputId ="my.plot")),
    column(6,ggiraphOutput(outputId = "interactive.plot"))
  )
)

server <- function(input, output){
  output$my.plot <- renderPlot({
    data = data.frame(x = 1:10, y= rnorm(10), z = 11:20)
    ggplot(data, aes(x = x, y = y)) + geom_col()

    #girafe(ggobj = xx)
  })
  output$interactive.plot <- renderggiraph({
    data = data.frame(x = 1:10, y= rnorm(10), z = 11:20)
    gg <- ggplot(data, aes(x = 1:10, y = …
Run Code Online (Sandbox Code Playgroud)

r shiny ggiraph

5
推荐指数
1
解决办法
362
查看次数

错误: !将 geom 转换为 grob 时出现问题。?错误发生在第一层

我正在运行此链接中的示例。重新安装 ggiraph 后,之前运行的相同代码返回此错误

\n
Error:\n! Problem while converting geom to grob.\n\xe2\x84\xb9 Error occurred in the 1st layer.\nCaused by error in `check.length()`:\n! \'gpar\' element \'lwd\' must not be length 0\nRun `rlang::last_error()` to see where the error occurred.\n
Run Code Online (Sandbox Code Playgroud)\n

有什么建议吗?

\n

interactive r ggplot2 ggiraph

5
推荐指数
1
解决办法
1万
查看次数

R Shiny ggiraph 和 d3heatmap 兼容性问题

我正在尝试向我的 Shiny 应用程序添加交互式热图,但我也有使用 ggiraph 的交互式图表。我目前正在使用 d3heatmap 包,但热图未在应用程序中呈现。我创建了一个玩具示例来说明这一点:

library(shiny)
library(ggiraph)
library(d3heatmap)

ui <- fluidPage(
    d3heatmapOutput('d3'),
    ggiraphOutput('gg')
)

server <- function(input, output, session) {

    # Create heatmap
    output$d3 <- renderD3heatmap({
        d3heatmap(matrix(1:100, nrow = 100, ncol = 100))
    })

    # Create ggiraph
    output$gg <- renderggiraph({
        p <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Width,
                              color = Species, tooltip = iris$Species) ) +
             geom_point_interactive()

        ggiraph(code = {print(p)})
    })
}

shinyApp(ui =  ui, server = server)
Run Code Online (Sandbox Code Playgroud)

总之,只有 ggiraph 渲染,但热图没有。但是,如果您注释掉 ggiraph 代码,则会呈现热图。我尝试切换加载包的顺序,但这仍然不起作用。

我目前在 R 3.2.2 上运行(我必须使用这个版本,因为公司服务器只在这个版本上运行,我的经理和我都没有更新它的权限)。我尝试下载 …

r shiny d3heatmap ggiraph

3
推荐指数
1
解决办法
586
查看次数

使用 javascript 基于交互式 ggplot 创建过滤器选择

我创建了以下 Rmarkdown 文件,以根据单击交互式 ggplot 进行选择。

\n

在 javascript 块中,我想使用从
交互式 ggplot 中的 onclick 事件获得的字母(A 或 B)来代替“A”。如果用户单击多边形 B,则“A”应变为“B”。

\n
---\noutput:\n  html_document\n---\n\n```{r, echo = FALSE, message = FALSE}\nlibrary(ggplot2)\nlibrary(ggiraph)\n\n# Rectangle A\ngroup_A <- data.frame(x1 = 0, \n                  x2 = 3, \n                  y1 = 0, \n                  y2 = 1, \n                  r = "A")\n\n# Polygon B\ngroup_B <- data.frame(x = c(3,4,4,0,0,3), \n                      y = c(0,0,2,2,1,1), \n                      r = "B")\n\np <- ggplot() + \n  geom_rect_interactive(data = group_A, \n                        aes(xmin = x1, xmax = x2, ymin = y1, \n …
Run Code Online (Sandbox Code Playgroud)

javascript r ggplot2 r-markdown ggiraph

3
推荐指数
2
解决办法
2172
查看次数

闪亮-如何使用ggiraph

我的数据集如下...

fund , sharpe , risk
abc , 1.5 , 7
def , 0 , 5

selectInput("n_breaks", label = "Risk Profile:", choices = c(1,2,3,4,5,6,7,8,9,10), selected = 7)

# Reactive 
selectedData <- reactive

  a <- mydata %>% filter(risk==as.numeric(input$n_breaks) & sharpe > 0)


renderPlot

  ggplot(selectedData(), aes(x = sharpe, y = returns, tooltip = fund, data_id = fund, color=sd)) +  geom_point_interactive(size=1)
Run Code Online (Sandbox Code Playgroud)

我试图在运行以下代码,但renderplot闪亮失败。请指教

ggiraph(code = {print(gg_point_3)}, tooltip_offx = 20, tooltip_offy = -10 )
Run Code Online (Sandbox Code Playgroud)

r shiny ggiraph

1
推荐指数
1
解决办法
1171
查看次数

标签 统计

ggiraph ×7

r ×7

shiny ×5

ggplot2 ×3

d3heatmap ×1

interactive ×1

javascript ×1

r-markdown ×1

tooltip ×1