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

scatter3d with different marker.size enables transparency

Open archmoj opened this issue 5 years ago • 8 comments
trafficstars

Transparency appears to be enabled by having different marker.sizes! View from our docs:

Screenshot from 2020-03-25 09-42-36

archmoj avatar Mar 25 '20 13:03 archmoj

For regular scatter this is intentional - bubble charts, which we define to be any chart with marker size set to an array - get some default transparency because overlap is common with large markers. I imagine we simply inherited that same behavior in scatter3d, so I might consider this a documentation issue rather than a bug.

alexcjohnson avatar Mar 25 '20 14:03 alexcjohnson

@alexcjohnson thanks for the clarification. This is still rather confusing. With different marker sizes, how one could force a graph not to have any transparency?

archmoj avatar Mar 25 '20 14:03 archmoj

JS demo.

archmoj avatar Mar 25 '20 14:03 archmoj

marker.opacity = 1 ?

alexcjohnson avatar Mar 25 '20 14:03 alexcjohnson

marker.opacity = 1 ?

That works for me!

archmoj avatar Mar 25 '20 15:03 archmoj

There is more than that happening:

  1. The marker size is somehow differently interpreted (markers change size w.r.t. passing the same size as a single value)
  2. The markers have a border if passing a size array while they don't for a single size value

Single size value:

image

Array of (same) size values:

image

Code to reproduce:

import numpy as np
import plotly.graph_objects as go

fig = go.Figure(layout=dict(template='plotly_dark',
                            scene=dict(xaxis=dict(visible=False),
                                       yaxis=dict(visible=False),
                                       zaxis=dict(visible=False))))
loc = np.array([[0, 0, 0], [1, 0, 0], [2, 0, 0], [3, 0, 0]])
trace = go.Scatter3d(x=loc[:, 0], y=loc[:, 1], z=loc[:, 2], mode='markers',
                     marker=dict(color=np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 1]]), 
#                                  size=[50, 50, 50, 50],  # uncomment for use with array
#                                  opacity=1,              # uncomment for use with array
#                                  size=50                 # uncomment for use with single value
                                ))
fig.add_trace(trace)
fig.show()

If not a bug, I would still argue this to be a serious design flaw (of an otherwise great library!)

robert-lieck avatar Jul 14 '21 19:07 robert-lieck

From trying out different values, it seems that size is interpreted as the radius if a single value is given and as the diameter if an array is given.

robert-lieck avatar Jul 14 '21 19:07 robert-lieck

The border can be turned off by explicitly specifying line=dict(width=0) in the marker dict.

robert-lieck avatar Jul 14 '21 19:07 robert-lieck