Can't change marker options when trace overlays another

Hi all,

I’m having trouble changing the marker shapes and colors when one plot is overlayed on top of another. Here’s an example:

library(plotly)
library(dplyr)

df <- data.frame(month = factor(c("Jan", "Feb", "Mar", "Apr", "Jan", "Feb", "Mar", "Apr"), levels = c("Jan", "Feb", "Mar", "Apr")),
  manufacturer = c("winky", "winky", "winky", "winky", "blinky", "blinky", "blinky", "blinky"),
                 units = c(50, 75, 50, 85, 20, 30, 40, 30),
                 item = c("widget", "blidget", "widget", "blidget", "widget", "blidget", "widget", "blidget"))

plot_ly(df) %>%
  add_trace(x = ~month,
            y = ~units,
            type = "scatter",
            color = ~manufacturer,
            mode = "lines") %>%
  add_trace(x = ~month,
            y = ~units,
            type = "scatter",
            mode = "markers",
            symbol = ~item,
            symbols = c("circle-open", "circle")
            )

Instead of the symbols of the marker trace being changed to open circles and circles, they stay the default circles and triangles, like in the png below. Am I doing something wrong? Thanks in advance for the help.

I’m speculating a bit - but would converting the ‘item’ column to a factor make any difference?

Unfortunately, that didn’t do the trick. Thanks for the suggestion though.

I found the solution here: solution. Apparently, it’s an undocumented quirk that you have to specify the symbols as an argument in the plot_ly() call.

1 Like

Created an account just to say thanks! I was starting to get very frustrated.