Legend "entrywidth" and "entrywidthmode" parameters appear to be ignored when knitting Rmd to HTML
Nessuno ha ancora preso questa issue.
- Lingua principale
- R
- Stelle
- 2.7k
- Fork
- 641
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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

I'm attaching the rel_table_filtered.csv file:
rel_table_filtered.csv
Thanks in advance!
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo l'esempio usando plot_ly e layout con legend entrywidth e entrywidthmode, quindi esegui il knit di Rmd in HTML e confronta diversi valori dei parametri. Controlla il file allegato rel_table_filtered.csv e il comportamento della legenda renderizzata; il lavoro è completato quando questi parametri controllano visibilmente le dimensioni del riquadro della legenda nell'output ottenuto con knit.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- r
- Ambito
- data-visualization
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100