#use of button plt.figure() ax = plt.axes([0.1,0.1,0.1,0.1]) gen = Button(ax, label=\'generator\') def generator(event): a.cla() a.hist(x) b.cla() b.hist(y)