Skip to content

Error bars displayed in incorrect order with color attribute assigned #762

Open
@saudiwin

Description

@saudiwin

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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions