Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

How to set color and symbol independently for a scatter plot

I’m trying to make a scatter plot where I can distinguish two features.
I want to have different colours for all the types of items I have, and then to use a different symbol for the origin of the items. When I do this, my legend shows the correct colors for each item type, then lists the origins showing the correct different shapes, but in three new colors, and then everything is plotted as the symbols in the origin color shown in the legend.
So now I can only distinguish my items by origin.
Is it possible to set the color and symbol independently?

pSets <- plot_ly(df, x = X, y = Y,color = itemType,colors =itemCol,type = “scatter”,mode=“markers”,symbol=origin,symbols=c(“dot”,“cross”,“diamond”))
pSets

Thanks!

Just to follow up, I’ve also tried setting different symbols and colors on the one group, rather than two separate groups. This gives the same behaviour with the legend showing groups “A” and “B” twice, once with the colors I chose, then once with the symbols I chose and some other random colors. So I can’t think of a work around for this…

testDf = data.frame(X = 1:4,Y = 4:1,group = c(“A”,“A”,“B”,“B”))
p = plot_ly(testDf,x=X,y=Y,color=group,symbol=group,colors=c("#000000","#AAAAAA"),symbols=c(“diamond”,“cross”),mode=“markers”)
p

(also don’t know how to show the output of my code in this forum, but this should run in R!)

Have you gotten any replies? I am dealing with the same issue and have no bright ideas …