1

I would like to plot a graph with a larger size on my dots, I have tried with sizes=100 but it didn't work,

here's the code :

import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

data = np.array([[1, 3, 'weekday'], [2, 2.5, 'weekday'],[3, 2.7, 'weekend'], [4, 2.8, 'weekend'], [5, 3, 'weekday'], [6, 3.1, 'weekday'], [7, 3, 'weekday'], [8, 3.1, 'weekday'], [9, 3.1, 'weekday'], [10, 3.1, 'weekend']])

# Creating a data frame with the raw data
dataset = pd.DataFrame(data, columns=['day', 'miles_walked', 'day_category'])

ax = sns.scatterplot(x='day', y='miles_walked', data=dataset, hue='day_category',sizes=100)
# Customize the axes and title
ax.set_title("Miles walked")
ax.set_xlabel("day")
ax.set_ylabel("total miles")
# Remove top and right borders
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
plt.show()

enter image description here

could somebody help please? thank you very much,

Sara
  • 353
  • 1
  • 3
  • 13
  • 1
    `sizes=` is used together with `size=` to let a column of the dataframe decide over the size of individual dots. https://seaborn.pydata.org/generated/seaborn.scatterplot.html – JohanC Dec 13 '21 at 10:49

2 Answers2

6

You can use the s parameter of the sns.scatterplot function as follow:

ax = sns.scatterplot(x='day', y='miles_walked', s=100, data=dataset, hue='day_category')
Antoine Dubuis
  • 4,974
  • 1
  • 15
  • 29
3

Is not sizes but s.

Replace

ax = sns.scatterplot(x='day', y='miles_walked', data=dataset, hue='day_category',sizes=100)

by

ax = sns.scatterplot(x='day', y='miles_walked', data=dataset, hue='day_category',s=100)
Boring Guy
  • 83
  • 2
  • 5