import matplotlib.pyplot as plt
import numpy as np
import random
plt.xlim((0, 100))
plt.ylim((0, 100))
total_x = None
total_y = None
total_c = None
for _ in range(12):
mu_x = random.randint(0, 100)
mu_y = random.randint(0, 100)
sig_x = random.random() * 5
sig_y = random.random() * 5
num = 50
c = random.random()
colors = np.ones(num) * c
print(c)
x = np.random.normal(loc=mu_x, scale=sig_x, size=num)
y = np.random.normal(loc=mu_y, scale=sig_y, size=num)
# plt.scatter(x, y, c=colors, s=1, cmap='viridis')
if total_x is None:
total_x = x.copy()
else:
total_x = np.concatenate([total_x, x])
if total_y is None:
total_y = y.copy()
else:
total_y = np.concatenate([total_y, y])
if total_c is None:
total_c = colors.copy()
else:
total_c = np.concatenate([total_c, colors])
plt.scatter(total_x, total_y, c=total_c, s=1, cmap='viridis')
plt.colorbar()
plt.show()
网友评论