plotly / plotly/plotly.R

Multicategory axis support

未关闭
#1,597 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
R
星标
2.7k
派生
641
PR 合并指标
30 天内没有已合并 PR

描述

Hi,

I am trying to use multicategory axes and get very inconsistent behavior. This is what I tested so far:

Bar charts:

I need to manually supply type = "multicategory" to the axis. This is opposed to what I have read for the python api, where this will happen automatically if your traces have arrays. see here

reprex

library(plotly)
two_f <- rbind(
  c("BB+", "BB+", "BB+", "BB", "BB", "BB"),
  c(16, 17, 18, 16, 17, 18)
)
p <- plot_ly() %>% 
  add_bars(x=two_f,y=c(1,2,3,4,5,6)) %>% 
  layout(barmode="relative")
p # no multicategory axis
p_multi <- p %>% layout(xaxis=list(side = "top", type = "multicategory"))
p_multi # multicategory axis on top

Heatmaps:

Thanks to michaelbabyn, I know how to create a multicategory x-axis for a heatmap. However, as opposed to bar charts, making a multicategory y-axis crashes, and trying to move the x-axis on top of the chart also crashes.

reprex

library(plotly)
q <- plot_ly() %>% 
  add_heatmap(
    x=rbind(c('aa', 'aa', 'bb', 'bb', 'cc', 'cc'), c(1,2,3,4,5,6)),
    y=c(1,2,3,4,5,6),
    z = array(seq(1,10, length.out = 36), c(6,6)))
q # this works
q_y <- plot_ly() %>% 
  add_heatmap(
    x=c(1,2,3,4,5,6),
    y=rbind(c('aa', 'aa', 'bb', 'bb', 'cc', 'cc'), c(1,2,3,4,5,6)),
    z = array(seq(1,10, length.out = 36), c(6,6))) 
## this would crash the Rstudio session:
## it should render something like https://codepen.io/michaelbabyn/pen/pMOOwM?editors=0010
# q_y

## this also breaks the session:
qx_top <- q %>% layout(xaxis=list(side = "top"))
# qx_top

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先在 RStudio 中运行提供的 plot_ly()、add_bars()、add_heatmap() 和 layout() 复现代码,并比较柱状图和热力图的情况。跟踪 x 轴和 y 轴的多类别轴处理;完成的标准是示例能够一致地渲染,包括热力图的 y 轴和置于顶部的 x 轴,且不会崩溃。

由索引模型根据 Issue 内容生成。

评估

技术栈
r
领域
data-visualization
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。