How can I change the size of the markers in a plotly express plot

I have a plot like

fig = px.scatter(filtered_data, x='x', y='y', color=arr, hover_data='id',
                color_discrete_map={'right': 'blue', 'left': 'red', 'both': 'green', 'none': 'grey'},
                title='Trajectory Plot with Colormap',
                labels={'X': 'X-axis', 'Y': 'Y-axis'},

where arr is a numpy array as


this works well except there are many points (like 9000) and the red dots obscure some of the green dots (giving a wrong impression)
I would like to reduce the size of the markers (I tried size and size_max but in one case it gave me HUGE dots and in the other one the green dots appeared white (you could only see then green when zooming))

This is part of the plot


this is when unmarking the red dots


Hi @Kansai ,

Have you try to change the size of markers from update_traces.
Example below change the marker size to 30px.

fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])

or you can refer to the docs below

Hope this help.

1 Like