plotly / plotly/plotly.R

Adding text shrinks bar chart area

Ouverte
#2,253 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
R
Étoiles
2.7k
Forks
641
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Exécutez le reprex R fourni avec plotly::plot_ly(), add_bars() et add_text(), puis comparez-le à la version sans add_text(). Suivez le comportement de la mise en page du graphique responsable de la réduction de la zone verticale du graphique en barres ; le travail est terminé lorsque l’ajout de texte n’augmente plus la distance entre la barre inférieure et le zéro de l’axe x.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
r
Domaine
data-visualization
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
42/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.