def draw_histogram(dataset_array, data_names, fname, fmt='png', nbins=10):
    '''
    Purpose::
        Draw histograms

    Input::
        dataset_array - a list of data values [data1, data2, ....]
        data_names    - a list of data names  ['name1','name2',....]
        fname  - a string specifying the filename of the plot
        bins - number of bins
    '''    
    fig = plt.figure()
    fig.dpi = 300
    ndata = len(dataset_array)
   
    data_min = 500.
    data_max = 0.
 
    for data in dataset_array:
        data_min = np.min([data_min,data.min()]) 
        data_max = np.max([data_max,data.max()]) 

    bins = np.linspace(np.round(data_min), np.round(data_max+1), nbins)
    for idata,data in enumerate(dataset_array):
        ax = fig.add_subplot(ndata, 1, idata+1)
        ax.hist(data, bins, alpha = 0.5, label=data_names[idata], normed = True)
        leg = ax.legend()
        leg.get_frame().set_alpha(0.5)
        ax.set_xlim([data_min-(data_min-data_max)*0.15, data_max+(data_max-data_min)*0.15])
        
    fig.savefig('%s.%s' %(fname, fmt), bbox_inches='tight', dpi=fig.dpi)
dataset/ETHPy150Open apache/climate/ocw/plotter.py/draw_histogram/swapped operands of `-`