1

I am trying to increase marker size with increasing x and y. However, I tried following a previous solution recommendation, but I get the error " scatter() got multiple values for argument 's'"

x=dataset.x
y=dataset.y
limits=-10,10
size= [n*2 for n in range(1, len(x)+1)]

plt.scatter(x,y,'o',c='blue',s=size)
plt.set_xlabel('x',color='black')
plt.set_ylabel('y',color='black',rotation=0)
plt.set_xlim(limits)
plt.set_ylim(limits)
plt.title('XY Dataset', fontsize=10)

Any recommendations? Also trying to figure out how to go from black dots to blue (example: point starts at black and gets lighter and lighter to a shade of blue.)

SpenceM
  • 51
  • 4
  • you can do it adding the argument s to the plot function : https://stackoverflow.com/questions/14827650/pyplot-scatter-plot-marker-size – AbouBakr Najdi Mar 29 '21 at 16:32

1 Answers1

3

You need to specify 'o' with the keyword 'marker', or it will be interpreted as the third argument, which is 's', and then 's' will be defined twice, thus the error of multiple values for 's'.

In addition, you have to remove '_set' from the other methods (set is only for axis).

This should work:

x=dataset.x
y=dataset.y
limits=-10,10
size= [n*2 for n in range(1, len(x)+1)]

plt.scatter(x, y, s=size, c='blue', marker='o')
plt.xlabel('x',color='black')
plt.ylabel('y',color='black',rotation=0)
plt.xlim(limits)
plt.ylim(limits)
plt.title('XY Dataset', fontsize=10)
shimeji42
  • 313
  • 1
  • 11