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

['none','left','right','none','both',.....]

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))

Edit:
This is part of the plot

image

this is when unmarking the red dots

image

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])
fig.update_traces(marker=dict(size=30))

or you can refer to the docs below

Hope this help.

1 Like