Scatter points at wrong coordinates when combining multicategory axis and colour
Open
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
When combining a multicategory axis and colour coding in a scatter plot, the mapping of the points seem to go wrong.
In p2 in the example below, the points appear at coordinates that are not in the data.
The problem can be resolved by first ordering the data (p4).
library(plotly)
d <- data.frame(
l1 = letters[11:15],
l2 = c('a', 'a', 'a', 'a', 'b'),
y = 1:10,
col = LETTERS[11:15],
stringsAsFactors = F
)
p1 <- plot_ly(
data = d,
x = list(~l2, ~l1),
y = ~y,
# color = ~col,
type = 'scatter',
mode = 'markers'
)
p2 <- plot_ly(
data = d,
x = list(~l2, ~l1),
y = ~y,
color = ~col,
type = 'scatter',
mode = 'markers'
)
d <- d[order(d$l1), ]
p3 <- plot_ly(
data = d,
x = list(~l2, ~l1),
y = ~y,
# color = ~col,
type = 'scatter',
mode = 'markers'
)
p4 <- plot_ly(
data = d,
x = list(~l2, ~l1),
y = ~y,
color = ~col,
type = 'scatter',
mode = 'markers'
)
subplot(p1, p2, p3, p4, nrows = 2, margin = .07) %>%
layout(annotations = list(
list(x = 0.1 , y = 1.05, text = "unordered/uncolored", showarrow = F, xref='paper', yref='paper'),
list(x = 0.9 , y = 1.05, text = "unordered/colored", showarrow = F, xref='paper', yref='paper'),
list(x = 0.1 , y = .45, text = "ordered/uncolored", showarrow = F, xref='paper', yref='paper'),
list(x = 0.9 , y = .45, text = "ordered/colored", showarrow = F, xref='paper', yref='paper')
)
)
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 running the provided R reproducible example and compare the unordered/colored scatter plot with the other panels. Trace the scatter handling for multicategory axes combined with color; done means points remain at the coordinates in the input data without requiring prior ordering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100