I'm trying to do a logistic map using the code below, but I'm struggling with making a scatter plot because I keep getting this error: "scatter() missing 1 required positional argument: 'y'". I understand I'm missing another 'y' but I don't know what I'm supposed to add.
allys = []
for r in np.arange(0.001, 4, 0.001):
y = np.random.rand()
for t in range(1000):
y = r * y * (1 - y)
if t > 959:
allys.append(y)
plt.scatter(allys, color = 'black', s = 1) #<--error from here
plt.xticks(np.arange(0, 4, 0.5))
plt.show()
TypeError: scatter() missing 1 required positional argument: 'y'"
I'm trying to do a logistic map using the code below, but I'm struggling with making a scatter plot because I keep getting this error: "scatter() missing 1 required positional argument: 'y'". I understand I'm missing another 'y' but I don't know what I'm supposed to add.
allys = []
for r in np.arange(0.001, 4, 0.001):
y = np.random.rand()
for t in range(1000):
y = r * y * (1 - y)
if t > 959:
allys.append(y)
plt.scatter(allys, color = 'black', s = 1) #<--error from here
plt.xticks(np.arange(0, 4, 0.5))
plt.show()
TypeError: scatter() missing 1 required positional argument: 'y'"
Share
Improve this question
asked Mar 12 at 20:50
magicgeniemagicgenie
1
1 Answer
Reset to default 0You are only passing in allys
. You need to also define a second array for the x
values and pass that into plt.scatter
as it requires x
and y
coordinates to work.
E.g.
allys = []
allxs = []
for r in np.arange(0.001, 4, 0.001):
y = np.random.rand()
for t in range(1000):
y = r * y * (1 - y)
if t > 959:
allys.append(y)
allxs .append(r)
plt.scatter(allxs , allys, color='black', s=1)