Skip to content

Marker symbol and line rendered in wrong order #1155

Open
@gorgitko

Description

@gorgitko

Given the code below, Plotly render the marker symbols and lines in wrong order. From df, you can see the point (3, 3) should be a circle without line. But it's rendered as a pentagon with the red circle:

library(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

df <- data.frame(x = seq(1, 10), y = seq(1, 10),
                 Sample_Group = rep(c("N", "T"), 5),
                 Symbol = rep(c("circle", "pentagon"), 5))
df$Symbol_Line <- sapply(df$Symbol, function(x) {ifelse(x == "pentagon", 2, 0)})
df
#>     x  y Sample_Group   Symbol Symbol_Line
#> 1   1  1            N   circle           0
#> 2   2  2            T pentagon           2
#> 3   3  3            N   circle           0
#> 4   4  4            T pentagon           2
#> 5   5  5            N   circle           0
#> 6   6  6            T pentagon           2
#> 7   7  7            N   circle           0
#> 8   8  8            T pentagon           2
#> 9   9  9            N   circle           0
#> 10 10 10            T pentagon           2

p <- plot_ly(df, x = ~x, y = ~y,
             type = "scatter", mode = "markers",
             color = ~Sample_Group,
             marker = list(symbol = ~Symbol,
                           size = 15,
                           line = list(width = ~Symbol_Line,
                                       color = "red")))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions