I want the markersize
in pyplot to correspond to a diameter in my experimental data.
Can I set the markersize
, so it always shows a circle with a diameter of 6*10^-8 m
? My x- and y-data is of the same scale.
font_size = 20
xmin = 0
xmax = np.sqrt(4) * 1e-6
ymin = 0
ymax = np.sqrt(4) * 1e-6
n_sim = 80
print("number of simulated dots:", n_sim)
density = n_sim / (xmax * ymax)
print("density:", density * 10 ** -12)
diameter = 60e-9
dots_sim = []
def no_nearby_dots(new_dot, dots_sim, min_distance):
for dot in dots_sim:
if np.sqrt((dot[0] - new_dot[0]) ** 2 + (dot[1] - new_dot[1]) ** 2) <= min_distance:
return False
return True
new_dot = True
dots_sim.append((np.random.uniform(xmin, xmax), np.random.uniform(ymin, ymax)))
failed_attempts = 0
while new_dot:
xp = np.random.uniform(xmin, xmax)
yp = np.random.uniform(ymin, ymax)
if no_nearby_dots((xp, yp), dots_sim, diameter):
dots_sim.append((xp, yp))
failed_attempts = 0
else:
failed_attempts += 1
if len(dots_sim) == n_sim:
new_dot = False
if failed_attempts > 1000:
new_dot = False
print("ERROR...exit loop")
break
x_sim = [dot[0] for dot in dots_sim]
y_sim = [dot[1] for dot in dots_sim]
fig = plt.figure(1)
ax1 = fig.add_subplot()
plt.title('simulated pattern', fontsize=font_size)
plt.plot(x_sim, y_sim, 'b.', label='QDs', markersize=14)
plt.xlabel('x [$\mathrm{\mu m}$]', fontsize=font_size)
plt.xticks(fontsize=font_size)
plt.ylabel('y [$\mathrm{\mu m}$]', fontsize=font_size)
plt.yticks(fontsize=font_size)
plt.ticklabel_format(axis='both', style='Sci', scilimits=(-6, -6), useMathText=1)
ax1.xaxis.get_offset_text().set_visible(False)
ax1.yaxis.get_offset_text().set_visible(False)
plt.show()