【问题标题】:In package `crosstalk`, are there have function `bsrows()` and `rows+cols` mixed?在 crosstalk 包中,是否混合了函数 `bsrows()` 和 `rows+cols`?
【发布时间】:2023-01-21 00:40:05
【问题描述】:

在包 crosstalk 中,有一个函数 bscols() 使绘图排成一行。但是我找不到功能 bsrows() 和 rows+cols mixed ,有没有包有这样的功能?谢谢!

library(plotly)
library(tidyr)
library(crosstalk)

m <- gather(mtcars, variable, value, -vs)
msd <- highlight_key(m, ~variable)
gg <- ggplot(msd, aes(factor(vs), value)) + 
  geom_jitter(alpha = 0.3)

bscols(
  widths = c(11, 6, 6),
  filter_select("id", "Select a variable", msd, ~variable, multiple = FALSE),
  ggplotly(gg, dynamicTicks = "y") %>% layout(margin = list(l = 30)),
  plot_ly(msd, x = ~jitter(vs), y = ~value) %>% add_markers(alpha = 0.3)
)

【问题讨论】:

  • 你有没有成功地解决这个问题?

标签: plotly crosstalk


【解决方案1】:

我一直在搜索相同的东西,直到意识到 12 是 crosstalk::bscols() 中每列的最大元素数。这意味着您只需为前一个小部件指定 widths = 12 即可将每个小部件放在下一行。通过调整宽度,您可以调整两列以及引入新行的时间。它可能不是您希望的界面,但它可以工作。这是一个示例,您的 widgests 位于不同的行(我添加了 htmltools 以使用中断):

library(plotly)
library(tidyr)
library(crosstalk)
library(htmltools)

m <- gather(mtcars, variable, value, -vs)
msd <- highlight_key(m, ~variable)
gg <- ggplot(msd, aes(factor(vs), value)) + 
  geom_jitter(alpha = 0.3)

bscols(
  widths = c(12, 12, 12),
  filter_select("id", "Select a variable", msd, ~variable, multiple = FALSE),
  htmltools::br(),
  ggplotly(gg, dynamicTicks = "y") %>% layout(margin = list(l = 30)),
  htmltools::br(),
  plot_ly(msd, x = ~jitter(vs), y = ~value) %>% add_markers(alpha = 0.3)
)

【讨论】:

    猜你喜欢
    • 2011-01-03
    • 2010-11-28
    • 1970-01-01
    • 2011-04-29
    • 2021-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-09
    相关资源
    最近更新 更多