plotly / plotly/plotly.R

Error bars displayed in incorrect order with color attribute assigned

Open
#762 7 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

When error_x is used along with a factor variable assigned to the color attribute in plot_ly, the resulting plot displays the error bars around the wrong points. Below is a working example using source code from the plotly for R book. You can see in the plot that the standard errors are being mapped to the wrong coefficients.

m <- lm(Sepal.Length ~ Sepal.Width * Petal.Length * Petal.Width, data = iris)

d <- broom::tidy(m) %>%
arrange(desc(estimate)) %>%
mutate(term = factor(term, levels = term),
one_col=cut(estimate,3,labels=c("Low","Medium","High")))
plot_ly(d, x = ~estimate, y = ~term,color=~one_col) %>%
add_markers(error_x = ~list(array=std.error,type="array")) %>%
layout(margin = list(l = 200))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproducible R example using plot_ly, add_markers, error_x, and the color factor one_col. Run it to confirm that standard errors are assigned to the wrong coefficients, then trace the color and error_x mapping until the bars align with their corresponding points.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.