plotly / plotly/plotly.R

pies and subplot not working as expected

未关闭
#655 4 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

Based on this StackOverflow post, it seems pie charts are not working as I would expect with subplot. I will admit though that this is my first ever attempt at pie charts in Plotly. I did verify by inspecting DOM that both pies do exist in the examples below.

    # devtools::install_github('ropensci/plotly")

    library(plotly)
    ds_r <- data.frame(labels1 = c("Baseline", "DTC", "Detailing", "Flex"),
                       values1 = c(63.5, 8.5, 20.6, 7.4))

    ds_l <- data.frame(labels2 = c("Baseline"),
                       values2 = c(100))

    p <- plot_ly(
      ds_r, labels = ~labels1, values = ~values1, type = "pie", 
      showlegend = F
    )

    p2 <- plot_ly(
      ds_l,labels = ~labels2, values = ~values2, type = "pie", 
      showlegend = F
    )


    subplot(p, p2, nrows = 1)

image

empty axes

    # devtools::install_github('ropensci/plotly")
    # an "empty" plotlyjs axis for layout
    emptyAxis <- list(
      title = "", 
      zeroline = FALSE,
      showline = FALSE, 
      showticklabels = FALSE, 
      showgrid = FALSE
    )

    p <- plot_ly(
      ds_r, labels = ~labels1, values = ~values1, type = "pie", 
      showlegend = F
    ) %>% layout(xaxis = emptyAxis, yaxis  = emptyAxis)

    p2 <- plot_ly(
      ds_l,labels = ~labels2, values = ~values2, type = "pie", 
      showlegend = F
    ) %>% layout(xaxis = emptyAxis, yaxis  = emptyAxis)


    subplot(p, p2, nrows = 1)

image

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先使用 plot_ly() 和 subplot() 运行两个可复现示例,分别测试带有和不带有空轴布局的情况。跟踪 subplot() 如何分配 pie traces 和坐标轴;当两个饼图无需空轴即可正确并排渲染时,即表示完成。

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

评估

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

把新 issue 发到你的邮箱

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