Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

seaborn scatterplot marker size for ALL markers

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.

like image 764
DataMan Avatar asked Oct 12 '18 18:10

DataMan


People also ask

How do you change markers in Seaborn?

Changing Marker Color on a Scatter Plot Behind the scenes, Seaborn scatter plots use the Matplotlib color styles. Here are the color codes for the basic colors you can use for your scatter plot markers. Pass the value in the argument column to the color parameter to change your marker colors.

What is hue in SNS scatterplot?

Hue can be used to group to multiple data variable and show the dependency of the passed data values are to be plotted. Syntax: seaborn.scatterplot( x, y, data, hue) Python3.

How do you set the marker size in Seaborn scatter plot?

To set the size of markers, we can use the s parameter. This parameter can be used since seaborn is built on the matplotlib module. We can specify this argument in the scatterplot() function and set it to some value. Alternatively, we can control the size of the points based on some variables.

How do you increase marker size in scatter plot?

Size in points^2 markersize'] ** 2. This can be taken literally. In order to obtain a marker which is x points large, you need to square that number and give it to the s argument. So the relationship between the markersize of a line plot and the scatter size argument is the square.


2 Answers

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)
like image 156
Xiaoyu Lu Avatar answered Oct 17 '22 19:10

Xiaoyu Lu


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)
like image 42
Rian.Lopes Avatar answered Oct 17 '22 21:10

Rian.Lopes