In the case you have different sample sizes, it may be difficult to compare the distributions with a single y-axis. For example:
import numpy as np import matplotlib.pyplot as plt #makes the data y1 = np.random.normal(-2, 2, 1000) y2 = np.random.normal(2, 2, 5000) colors = ['b','g'] #plots the histogram fig, ax1 = plt.subplots() ax1.hist([y1,y2],color=colors) ax1.set_xlim(-10,10) ax1.set_ylabel("Count") plt.tight_layout() plt.show()

In this case, you can plot your two data sets on different axes. To do so, you can get your histogram data using matplotlib, clear the axis, and then re-plot it on two separate axes (shifting the bin edges so that they don't overlap):
#sets up the axis and gets histogram data fig, ax1 = plt.subplots() ax2 = ax1.twinx() ax1.hist([y1, y2], color=colors) n, bins, patches = ax1.hist([y1,y2]) ax1.cla() #clear the axis #plots the histogram data width = (bins[1] - bins[0]) * 0.4 bins_shifted = bins + width ax1.bar(bins[:-1], n[0], width, align='edge', color=colors[0]) ax2.bar(bins_shifted[:-1], n[1], width, align='edge', color=colors[1]) #finishes the plot ax1.set_ylabel("Count", color=colors[0]) ax2.set_ylabel("Count", color=colors[1]) ax1.tick_params('y', colors=colors[0]) ax2.tick_params('y', colors=colors[1]) plt.tight_layout() plt.show()
