plotly / plotly/plotly.R

Adding text shrinks bar chart area

Aperta
#2,253 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

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

Adding text shrinks the bar chart area. Below we render a bar chart where the bars are on the x-axis. The add_text() call actually vertically shrinks the area of the plot, such that the distance from the bottom bar to the x-axis "0" is increased. If you run this output without the add_text() call, you'll see that the vertical width of the bar charts increases.

Adding text should not have an effect on the bar chart.

# Shrunken plot area
require(plotly)
#> Loading required package: plotly
#> Loading required package: ggplot2
#> 
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#> 
#>     last_plot
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following object is masked from 'package:graphics':
#> 
#>     layout

cats = c(letters, paste0(letters,'2'), paste0(letters,'3'), paste0(letters,'4') )

data = data.frame(
  y_axis_cat = rep(cats,8),
  x_axis_num = rep(5,length(cats)*8),
  cat = rep(paste0('Cat ',1:8), length(cats))
)

p = plotly::plot_ly(data) %>%
  plotly::add_bars(
    x = ~x_axis_num,
    y = ~y_axis_cat,
    color=~cat
  ) %>%
  plotly::add_text(
    x = 40,
    y = ~y_axis_cat,
    text = '40'
  ) 

Created on 2023-04-10 with reprex v2.0.2

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Esegui il reprex R fornito con plotly::plot_ly(), add_bars() e add_text(), quindi confrontalo con la versione senza add_text(). Traccia il comportamento del layout del grafico responsabile della riduzione dell’area verticale del grafico a barre; il lavoro è completato quando l’aggiunta di testo non aumenta più la distanza tra la barra inferiore e lo zero dell’asse x.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
r
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.