Generation

generate functionTue, 21 Mar 2023

Write code that draws two histograms A and B superimposed on each other with bins=12 and legend

import matplotlib.pyplot as plt def draw_histogram(a,b,legend): plt.hist(a, bins=12) plt.hist(b, bins=12) plt.title("Normal Distribution") plt.xlabel("x") plt.ylabel("Frequency") plt.legend(legend) plt.show() A = [1,2,3,4,5,6,7,8,9,10,11,12] B = [1,2,3,4,5,3,3,2,2,2,2,1] legend = ["A", "B"] draw_histogram(A,B,legend)

Questions about programming?Chat with your personal AI assistant