thepensioner
thepensioner

Reputation: 11

Changing size of scatter plot points by value

I am trying to make a scatter plot and scale the size of points on the basis of numbers from a different list.

So I am making a scatter plot of y vs x but the size of each point will depend on the corresponding number from s. Essentially, the larger the value of the element from s bigger would be the point on the scatter plot.

y = [2.2, 3.1, 4.3, 4.9, 5.1]
x = [0.03, 0.3, 0.4, 0.6, 0.7]
s = [48, 134, 391, 203, 193]

fig, ax = plt.subplots()
ax.scatter(x, y)

Any ideas?

Thanks in advance!

Upvotes: 0

Views: 2346

Answers (1)

crayxt
crayxt

Reputation: 2405

You are so close

ax.scatter(x, y, s=s)

Upvotes: 1

Related Questions