My problem statement is the following:
Use NumPy and Matplotlib to draw a scatterplot of uniform random (x, y) values all drawn from the [0, 1] interval.
The following is what I have tried:
The output of the above is my plot with a single large dot in the center.
For some reason I am only generating and plotting a single x,y pair.
I think I need a for loop but I lack knowledge of matplotlib+nump y.
Is anyone able to help me with this?
Use NumPy and Matplotlib to draw a scatterplot of uniform random (x, y) values all drawn from the [0, 1] interval.
The following is what I have tried:
Code:
import matplotlib.pyplot as plt
import numpy as np
import random
# Fixing random state for reproducibility
np.random.seed(19680801)
N = 50
x = random.uniform(0, 1)
y = random.uniform(0, 1)
colors = random.uniform(0, 1)
#for ...
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.title('Exercise 2 - Drawing a plot')
plt.xlabel('x')
plt.ylabel('y')
plt.show()
For some reason I am only generating and plotting a single x,y pair.
I think I need a for loop but I lack knowledge of matplotlib+nump y.
Is anyone able to help me with this?
Comment