# How to assign more than 6 different marker symbols in 3D scatter plot legend

**URL:** <https://community.plotly.com/t/how-to-assign-more-than-6-different-marker-symbols-in-3d-scatter-plot-legend/92764>\
**Category:** Plotly R\
**Tags:** question\
**Created:** [June 17, 2025, 8:52pm UTC](https://community.plotly.com/t/how-to-assign-more-than-6-different-marker-symbols-in-3d-scatter-plot-legend/92764 "2025-06-17T20:52:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yunk8823](https://avatars.discourse-cdn.com/v4/letter/y/439d5e/32.png) [@Yunk8823](https://community.plotly.com/u/Yunk8823)\
**Post date:** [June 17, 2025, 8:52pm UTC](https://community.plotly.com/t/how-to-assign-more-than-6-different-marker-symbols-in-3d-scatter-plot-legend/92764/1 "2025-06-17T20:52:30Z")

</div>

Dear plot\_ly community,

I am using Plotly in R on the following environment:  
• R version: 4.3.3 (2024-02-29)  
• RStudio version: 2023.06.2 Build 561  
• OS: macOS 15.5 (24F74) on MacBook Pro M2  
• Plotly package version: 4.10.4

I am creating a 3D scatter plot using plotly::plot\_ly with multiple groups (identified by SSname). I want to assign a unique marker symbol to each group and show them correctly in the legend.

However, even though I define more than 6 symbols, the legend only uses about 6 distinct shapes and then reuses them. I would like to know:  
1. Is there a limitation on the number of distinct symbol values recognized in 3D scatter plots?  
2. How can I ensure that at least 15 or more unique marker symbols are shown correctly in the legend?

Here is a simplified version of the code I’m using:

```r
library(plotly)

# Dummy dataset
set.seed(123)
sada2 <- data.frame(
  SSname = rep(paste0("Group", 1:15), each = 10),
  KabenHS = runif(150, 0, 360),
  KabenS = runif(150, 0, 100),
  KabenV = runif(150, 0, 100)
)

# Unique marker symbols（15種類）
symbols <- c(
  "circle", "square", "diamond", "cross", "x", "triangle-up",
  "triangle-down", "triangle-left", "triangle-right",
  "star", "hexagram", "pentagon", "hexagon",
  "hourglass", "bowtie"
)

ss_names <- unique(sada2$SSname)
symbol_map <- setNames(symbols[1:length(ss_names)], ss_names)

fig <- plot_ly(type = "scatter3d", mode = "markers")

for (ss in ss_names) {
  sub_data <- sada2[sada2$SSname == ss,]
  
  # HSV色を正規化し、安全にベクトルとして渡す
  h_vec <- (sub_data$KabenHS ) / 360
  s_vec <- sub_data$KabenS / 100
  v_vec <- sub_data$KabenV / 100

  # hsv()はベクトル長が一致している必要がある
  colors <- hsv(h = h_vec, s = s_vec, v = v_vec)

  fig <- add_trace(
    fig,
    data = sub_data,
    x = ~KabenHS,
    y = ~KabenS,
    z = ~KabenV,
    mode = "markers",
    name = ss,
    marker = list(
      color = colors,
      size = 4,
      symbol = symbol_map[[ss]]
    )
  )
}

fig <- layout(fig, legend = list(
  font = list(size = 14),
  itemsizing = "constant"
))

fig

```

Despite specifying 15 distinct symbols, the legend still shows repeated symbols. Is this a known limitation? Are there any workarounds?

Thank you for your support

 ![スクリーンショット 2025-06-17 22.39.23](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/2/7/27c4ab5c2b5d78153985f981769b350d8c2d84fb.png)

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [June 18, 2025, 5:30am UTC](https://community.plotly.com/t/how-to-assign-more-than-6-different-marker-symbols-in-3d-scatter-plot-legend/92764/2 "2025-06-18T05:30:04Z")

</div>

Hello @Yunk8823 welcome!

At first glance this looks like a bug. Did you try repeating the symbols which work? I assume that the symbol names are not recognized somehow and fall back to the default symbol. Something like that:

```r
symbols <- c(
 "circle", "square", "diamond", "cross", "x", 
 "circle", "square", "diamond", "cross", "x", 
 "circle", "square", "diamond", "cross", "x", 
 "circle", "square"
)

```

Did you try with other symbols as per [Single-page reference in R](https://plotly.com/r/reference/#scatter-marker-symbol)?

I tried with `python` an it worked as expected:

```python
import plotly.graph_objects as go
from plotly.validators.scatter.marker import SymbolValidator
import numpy as np

x = np.arange(3)
y = np.arange(1,4)

raw_symbols = SymbolValidator().values
namestems = []
namevariants = []
symbols = []
for i in range(0,len(raw_symbols),3):
    name = raw_symbols[i+2]
    symbols.append(raw_symbols[i])
    namestems.append(name.replace("-open", "").replace("-dot", ""))
    namevariants.append(name[len(namestems[-1]):])
    
fig = go.Figure()

for idx, symbol in enumerate(symbols):  
    fig.add_trace(
        go.Scatter(
            x=x+idx*2,
            y=y,
            mode="markers",
            marker=dict(
                symbol=symbol,
                size=15,
            ),
        )
    )
fig.show()

```

mrep marker symbols
