Adding text shrinks bar chart area
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the supplied R reprex with plotly::plot_ly(), add_bars(), and add_text(), then compare it with the version without add_text(). Trace the plot layout behavior responsible for the reduced vertical bar-chart area; done means adding text no longer increases the distance between the bottom bar and the x-axis zero.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100