Adding text shrinks bar chart area
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- R
- Sterne
- 2.7k
- Forks
- 641
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Führen Sie das bereitgestellte R-reprex mit plotly::plot_ly(), add_bars() und add_text() aus und vergleichen Sie es anschließend mit der Version ohne add_text(). Verfolgen Sie das Plot-Layout-Verhalten, das für den verkleinerten vertikalen Bereich des Balkendiagramms verantwortlich ist; die Aufgabe ist abgeschlossen, wenn das Hinzufügen von Text den Abstand zwischen dem unteren Balken und dem Nullpunkt der x-Achse nicht mehr vergrößert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- r
- Bereich
- data-visualization
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 42/100