简体   繁体   中英

How to change scatter point size on Seaborn's relplot (seaborn.relplot not regplot)? Seaborn 0.9.0

The code below plots, however the scatter points are too large.

sns.relplot(x='columnx', y='columny', hue='cluster', data=df)

I would like to change the size of the scatter points. Neither of these plot.

sns.relplot(x='columnx', y='columny', hue='cluster', scatter_kws={'s':.01}, data=df)

sns.relplot(x='tmmx', y='NDVI', hue='cluster', kwargs={'s':.01}, data=df)

Seaborn Documentation says:

kwargs : key, value pairings

 Other keyword arguments are passed through to the underlying plotting function. 

I believe the 'underlying plotting function' is seaborn.scatterplot(), which says:

kwargs : key, value mappings

 Other keyword arguments are passed down to plt.scatter at draw time. 

To create a df:

d = {'columnx': [1, 2, 3,], 'columny':[2,4,5], 'cluster':[0,1,0]}

df = pd.DataFrame(data=df)

由于基础函数是matplotlib.pyplot.scatter(x, y, s=None) ,因此将s = None填充为合适的整数会更改所有点的大小。

Given your data and question choose your size between 1 and some larger number and figure out what works for you with the s argument as mentioned above. Just being more clear on how the end code should look.

sns.relplot(
    x='columnx', y='columny', hue='cluster', data=df, s=10)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM