plotly.R icon indicating copy to clipboard operation
plotly.R copied to clipboard

Bug: Colorbar duplicated when specifying color and symbol in marker argument

Open Apompetti-Cori opened this issue 2 years ago • 1 comments


Whenever I plot a 3d scatter with color and symbol, the colorbar seems to be duplicated. This issue does not occur when symbol is removed so I believe it is an issue with the combination of the two.

library(tidyverse)
mtcars <- mtcars %>% mutate(make = substr(word(rownames(mtcars), 1), 1, 1), model = word(rownames(mtcars), 2))
pca <- PCAtools::pca(t(mtcars[,c(1:4)]), metadata = mtcars[,c("carb","gear","qsec", "make", "model")])
p <- plot_ly(data = pca$rotated, 
             x = ~PC1, y = ~PC2, z = ~PC3,
             height = 600,
             marker = list(color = pca$metadata$qsec,
                           colorscale = "Jet",
                           colorbar = list(title = "Test",
                                           y = 0.5, x = 0, len = 0.5)),
             symbol = pca$metadata$make)

p

newplot (2)

Apompetti-Cori avatar Aug 09 '23 16:08 Apompetti-Cori

I'm facing a very similar issue. I'm combining a colorscale with 2 different symbols. However, plotly creates 3 different colorscales (a default viridis one, and one custom colorscale for each symbol). And, it puts the default (viridis) on top of the others with no option to control it.

I described my issue on stackoverflow before being pointed to this bug report https://stackoverflow.com/questions/79400241/r-plotly-with-2-different-symbols-and-using-colorscale-are-messed-up-with-highli

txemaheredia avatar Feb 05 '25 10:02 txemaheredia