def plot_histograms(ertobj, keys, **kwargs):
    if isinstance(ertobj, pd.DataFrame):
        df = ertobj
    else:
        df = ertobj.data
    if df.shape[0] == 0:
        raise Exception('No data present, cannot plot')
    if isinstance(keys, str):
        keys = [keys, ]
    figures = {}
    merge_figs = kwargs.get('merge', True)
    if merge_figs:
        nr_x = 2
        nr_y = len(keys)
        size_x = 15 / 2.54
        size_y = 5 * nr_y / 2.54
        fig, axes_all = plt.subplots(nr_y, nr_x, figsize=(size_x, size_y))
        axes_all = np.atleast_2d(axes_all)
    for row_nr, key in enumerate(keys):
        print('Generating histogram plot for key: {0}'.format(key))
        subdata_raw = df[key].values
        subdata = subdata_raw[~np.isnan(subdata_raw)]
        subdata = subdata[np.isfinite(subdata)]
        subdata_log10_with_nan = np.log10(subdata[subdata > 0])
        subdata_log10 = subdata_log10_with_nan[~np.isnan(
            subdata_log10_with_nan)
        ]
        subdata_log10 = subdata_log10[np.isfinite(subdata_log10)]
        if merge_figs:
            axes = axes_all[row_nr].squeeze()
        else:
            fig, axes = plt.subplots(1, 2, figsize=(10 / 2.54, 5 / 2.54))
        ax = axes[0]
        ax.hist(
            subdata,
            _get_nr_bins(subdata.size),
        )
        ax.set_xlabel(
            units.get_label(key)
        )
        ax.set_ylabel('count')
        ax.xaxis.set_major_locator(mpl.ticker.MaxNLocator(5))
        ax.tick_params(axis='both', which='major', labelsize=6)
        ax.tick_params(axis='both', which='minor', labelsize=6)
        if subdata_log10.size > 0:
            ax = axes[1]
            ax.hist(
                subdata_log10,
                _get_nr_bins(subdata.size),
            )
            ax.set_xlabel(r'$log_{10}($' + units.get_label(key) + ')')
            ax.set_ylabel('count')
            ax.xaxis.set_major_locator(mpl.ticker.MaxNLocator(5))
        else:
            pass
        fig.tight_layout()
        if not merge_figs:
            figures[key] = fig
    if merge_figs:
        figures['all'] = fig
    return figures