plotly / plotly/plotly.R

Legend "entrywidth" and "entrywidthmode" parameters appear to be ignored when knitting Rmd to HTML

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

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

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

説明

I'm trying to use plotly to plot several stacked barplots of the same size each. Each barplot has legend elements of increasing size, and I would like to set the dimensions of the legend box, instead of the legend box being the size of the longest legend element. I've found the parameters entrywidth and entrywidthmode and tried using them to set this graphic setting, but the plots look exactly the same independently on what values I use.

The data looks like this:

> head(rel_table_filtered)
                                Class Relative_frequency  Sample
3      Bacteria;Bacteria;Unclassified        0.001547047 ileum_A
4  Bacteria;Bacteria;Actinobacteriota        0.137521410 ileum_A
5      Bacteria;Bacteria;Bacteroidota        0.111055859 ileum_A
8  Bacteria;Bacteria;Desulfobacterota        0.011989613 ileum_A
9        Bacteria;Bacteria;Firmicutes        0.707497652 ileum_A
11   Bacteria;Bacteria;Proteobacteria        0.025857782 ileum_A

The function simplified function I'm using to plot the barplots is the following. Wheter I put 0.9, 0.5, 1/8, etc, on the entrywitdthmode parameter, the plot looks the same. I've also tried with autosize=FALSE and with height and width parameters on the plot_ly function, without success.

fig <- plot_ly(rel_table_filtered, type = "bar", y = ~Sample, x= ~Relative_frequency, color = ~Class, orientation = "h") %>%
    layout( barmode = 'stack', xaxis = list(title = ''), yaxis = list(title = '%'), autosize = T, legend = list(entrywidthmode = "fraction", entrywidth = 0.9), hoverlabel = list(namelength=-1) )

fig

image

I'm attaching the rel_table_filtered.csv file:
rel_table_filtered.csv

Thanks in advance!

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

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

はじめの一歩

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

調査の方向性

まず、legend entrywidth と entrywidthmode を指定した plot_ly と layout を使って例を再現し、次に Rmd を HTML に knit して、異なるパラメーター値を比較します。添付された rel_table_filtered.csv と、レンダリングされた凡例の挙動を確認してください。knit した出力で、これらのパラメーターによって凡例ボックスの寸法が目に見えて制御されれば完了です。

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

評価

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

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

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