plotly / plotly/plotly.R

legend positioning

未关闭
#195 3 条评论 2 个 reaction 已指派 1 人 在 GitHub 查看

@13bzhang 已经在做这个了。

开始于 2015年7月9日。

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

描述

a lot of legends are coming out with weird positioning (https://github.com/ropensci/plotly/issues/194#issuecomment-87780687)

a couple things to work out:

  • move the horizontal position of the legend to the right more

    layout$legend$x <- 1.0 # move it to the right a bit
    layout$legend$xanchor <- "left" 
    layout$annotation[[1]]$x <- 1.01
    layout$annotation[[1]]$xanchor <- "left"
    
  • the vertical position of the legend should stay in the middle, with yanchor <- "middle"

    layout$legend$y <- 0.5 # page middle
    layout$legend$yanchor <- "middle" 
    

    but we should compute the vertical position of the legend title annotation to remain above the legend, no matter how many entries. For now, we could hardcode a mapping in that would work for default font-sizes:

    • 8 legend entries: annotation$y <- 0.65 (from manual inspection)
    • 1 legend entry: annotation$y <- 0.52 (manual inspection)
    • -> annotation$y <- 0.14125 * number_of_legend_items - 0.48 (computed from those two points above)

    @alexcjohnson, how do you think legend titles will work in the future? a separate attribute inside legend?

  • manual legend positions from ggplot: https://github.com/ropensci/plotly/blob/add-r-cookbook-tests/tests/cookbook-test-suite/legends.R#L109-L122

cc @tdhock , @cpsievert

贡献指南

打开贡献指南

从这里开始

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

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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