Wrong width of bar in bar plots
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
I would have expected a single bar with a width of 0.05 here:
library(plotly)
plot_ly(
type = 'bar',
x = 0.2,
y = 10,
width = 0.05
) %>%
layout(
xaxis=list(range=c(0,1))
)
Instead, I get a single bar with width 0.6 (and not 0.05).
Similarily, I would have expected two bars, each of width 0.05 here:
plot_ly(
type = 'bar',
x = c(0.2, 0.5),
y = c(10, 8),
width = 0.05
) %>%
layout(
xaxis=list(range=c(0,1))
)
Instead, it shows two bars, but not of width 0.05.
Only if I'm plotting 4 bars (or more) do I get the correct width (of 0.05) for each:
plot_ly(
type = 'bar',
x = c(0.2, 0.5, 0.6, 0.7),
y = c(10, 8, 7, 3),
width = 0.05
) %>%
layout(
xaxis=list(range=c(0,1))
)
Checking with a Javascript codepen, using
var trace0 = {
type: 'bar',
x: [0.2],
y: [10],
width: 0.05
}
var layout = {
xaxis: {range: [0, 1]}
}
var data = [trace0]
Plotly.newPlot('myDiv', data, layout);
does give the expected result.
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
Start by reproducing the three R examples using plot_ly() and layout(), then compare their bar widths with the JavaScript CodePen example. Trace how the R inputs are translated into the bar plot entry point; done means one- and two-bar plots honor width = 0.05 as the four-bar plot and JavaScript example do.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100