Reputation: 33
I would like to identify the next combined histogram with a legend
import matplotlib.pyplot as plt
nbins=10
plt.title('Gaussian random numbers B-M')
plt.axis([-3, 3, 1, 25])
plotcos = plt.hist(coseno, nbins, alpha=.8, edgecolor = 'black', linewidth=1)
plotsen = plt.hist(seno, nbins, alpha=.8, edgecolor = 'black', linewidth=1)
plt.show()
Upvotes: 1
Views: 3008
Reputation: 39052
I assume by "next combined histogram" you mean individual legends for each histogram. Just use the label
parameter in both your plot commands and then show the legend using plt.legend()
as
plotcos = plt.hist(coseno, nbins, alpha=.8, edgecolor = 'black', linewidth=1, label='coseno')
plotsen = plt.hist(seno, nbins, alpha=.8, edgecolor = 'black', linewidth=1, label='seno')
plt.legend()
Upvotes: 1