plotly / plotly/plotly.R

Setting anchor = "free" in R subplot() causes the graph to disappear

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

还没有人认领这个 Issue。

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

描述

I'm trying to build a subplot of stacked scatter plots, where there are multiple axes on each scatter plot.

Below is an example of the type of plot. To position the yaxis side-by-side, I have layout(yaxis(anchor = "free")) set am using position to place the axis.

image

All my attempts to set anchor = "free" in subplots left my plot space completely blank. Some testing revealed that even a subplot constructed from a single plot will not display if anchor="free"

Please see below REPREX.

require(plotly)
df <- data.frame(x = 1:10, y = 1:10, y2 = 10:19)
plt <- plot_ly(data = df) %>%
  add_trace(x = ~x, y = ~y,
            mode = "markers", type = "scatter",
            yaxis = "y") %>%
  add_trace(x = ~x, y = ~y2,
            mode = "markers", type = "scatter",
            yaxis = "y2") %>%
  layout(
    xaxis = list(
      domain = c(.12, .88)
    ),
    yaxis = list(
      title = "y_1"
    ),
    yaxis2 = list(
      title = "y_2",
      anchor = "free",
      position = .10,
      overlaying = "y"
    ),
    margin = list(
      pad = 60
    )
  )
subplot(plt)

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先运行提供的 R reprex,并使用 plot_ly()、layout() 和 subplot(),确认 anchor = "free" 会生成空图。然后跟踪 subplot() 如何处理 yaxis 和 yaxis2 设置,尤其是 anchor、position 和 overlaying。完成的标准是 subplot 能够渲染其 traces,同时保留自由定位的坐标轴。

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

评估

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

把新 issue 发到你的邮箱

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