plotly / plotly/plotly.R

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

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

还没有人认领这个 Issue。

主要语言
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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用带有 legend entrywidth 和 entrywidthmode 的 plot_ly 和 layout 重现示例,然后将 Rmd knit 为 HTML,并比较不同的参数值。检查附加的 rel_table_filtered.csv 以及渲染后的图例行为;当这些参数能够在 knit 生成的输出中明显控制图例框的尺寸时,即表示完成。

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

评估

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

把新 issue 发到你的邮箱

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