How would I hide the output of plt.hist()
when also trying to plot its top curve?
data = {'first': np.random.normal(size=[100]),
'second': np.random.normal(size=[100]),
'third': np.random.normal(size=[100])}
for data_set, values in sorted(data.items()):
y_values, bin_edges, _ = plt.hist(values, bins=20)
bin_centers = 0.5*(bin_edges[1:] + bin_edges[:-1])
plt.plot(bin_centers, y_values, '-', label=data_set)
legend = plt.legend()
plt.show()
similar question, but I can't just clear the plot since there's a loop. Hide histogram plot