seaborn scatterplot marker size for ALL markers

PythonMatplotlibSeaborn

Python Problem Overview


I can't find out anywhere how to change the marker size on seaborn scatterplots. There is a size option listed in the documentation but it is only for when you want variable size across points. I want the same size for all points but larger than the default!

I tried making a new column of integers in my dataframe and set that as the size, but it looks like the actual value doesn't matter, it changes the marker size on a relative basis, so in this case all the markers were still the same size as the default.

Edit: here's some code

ax = sns.scatterplot(x="Data Set Description", y="R Squared", data=mean_df)
plt.show()

I just tried something and it worked, not sure if it's the best method though. I added size=[1, 1, 1, 1, 1, 1] and sizes=(500, 500). So essentially I'm setting all sizes to be the same, and the range of sizes to be only at 500.

Python Solutions


Solution 1 - Python

You can do so by giving a value to the s argument to change the marker size.

Example:

ax = sns.scatterplot(x="Data Set Description", y="R Squared", data=mean_df, s=10)

Solution 2 - Python

About the update of the legend size, I got it by the attribute 'markerscale' from matplotlib.pyplot.legend

> markerscalefloat, default: rcParams["legend.markerscale"] (default: 1.0) The relative size of legend markers compared with the originally drawn ones.

plt.legend(markerscale=2)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDataManView Question on Stackoverflow
Solution 1 - PythonXiaoyu LuView Answer on Stackoverflow
Solution 2 - PythonRian.LopesView Answer on Stackoverflow