plotly / plotly/plotly.R

size argument passed to annotations not respected?

オープン
#745 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug enhancement
主要言語
R
スター
2.7k
フォーク
641
PR マージ指標
30日以内にマージされた PR はありません

説明

I understand this issue has a chance of being an off-topic implementation issue. If so, please accept my sincere apologies in advance. Frank Harrell reported he is unable to change size of the annotated text using the code below.

require(plotly)
p <- plot_ly()
p <- add_markers(p,x=~1:2, y=~1:2)
p <- add_annotations(p, x=~c(1.1, 2.1), y=~c(1.2, 2.4),
                     text=~c('XXX','YYY'), size=~c(7,20))
p

I was unable to account for size of text using the 'old' method using 'layout' (as discussed in #744).

ann <- data.frame(x = c(1.1, 2.1),
                  y = c(1.2, 2.4),
                  size = c(10, 20),
                  text = c("XXX", "YYY"))
xy <- data.frame(x = c(1, 2), y = c(1, 2))

a <- vector("list", nrow(ann))

for (i in 1:nrow(ann)) {
  a[[i]] <- list(
    x = ann$x[i],
    y = ann$y[i],
    text = ann$text[i],
    xref = "x", yref = "y",
    showarrow = TRUE,
    size = ann$size[i]
  )
}

plot_ly(xy, x = ~x, y = ~y) %>%
  add_markers() %>%
  layout(annotations = a)

@cpsievert suggested using add_annotations but I'm a bit lost on how to pass on the size argument. Based on the documentation and some examples scattered over the internet, I tried

plot_ly(xy, x = ~x, y = ~y) %>%
  add_markers() %>%
  add_annotations(text = ~text, font = list(size = ~size), data = ann)

with no luck. Is there something I'm doing wrong?

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、font = list(size = ~size) の形式と以前のレイアウト方式を含め、提供されている add_annotations の例を再現します。add_annotations のエントリポイントをたどってアノテーションのサイズがどのように渡されるかを確認し、次に、アノテーションが要求された行ごとのサイズでレンダリングされることを検証します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
r
領域
data-visualization
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。