def main():
    figure = Plot.new_figure(figsize=(5,10))

    data_path = lambda x: os.path.join('json', 'fig_4d_difference_' + x + '_lifetime.json')
    fits = [ Fit(data_path(fig)) for fig in ['large', 'larger'] ]

    for fit in fits:
        fit.maps['value_transforms']['τ'] = lambda x: '%.2E' % round(x, 2)
        fit.meta['contact_type'] = 'transparent'

    plots = []
    for idx, fit in enumerate(fits):
        n, m = 2, 1

        options = {}
        if idx != 0: options['sharex'] = plots[idx - 1].plt

        plot = Plot(fit, figure.add_subplot(n, m, (m * idx + 1), **options))
        plot.id = 'd.' + str(idx + 1)
        plots.append(plot)

    for plot in plots:
        plot.plot_data()
        plot.plot_fit()
        plot.add_ylabel()
        plot.add_parameter_overlay()

    plots[-1].add_xlabel()
    matplotlib.pyplot.setp(plots[0].plt.get_xticklabels(), visible=False)

    figure.savefig(os.path.join('build', 'plot_fits_large_lifetime.eps'), transparent=True)
    plots[0].fit.save_info('build/plot_fits_large_lifetime_info.tex', 'plotFitsLargeLifetimeInfo')
    Plot.close_figure(figure)
def main():
    figure = Plot.new_figure(figsize=(5,10))
    fit_ids = ['a', 'b', 'c', 'd']

    def data_path(fit_id):
        if fit_id == 'c':
            fit_type = 'parallel'
        else:
            fit_type = 'difference'
        return os.path.join('json', 'fig_4' + fit_id + '_' + fit_type + '.json')

    fits = [ Fit(data_path(fig)) for fig in fit_ids ]

    for fit in fits[0:3]:
        fit.maps['value_transforms']['Ω_C'] = lambda x: '%.2E' % round(x, 2)

    for i in (0, 1): fits[i].meta['contact_type'] = 'tunneling'
    fits[2].meta['contact_type'] = 'pinhole'
    fits[3].meta['contact_type'] = 'transparent'

    plots = []
    for idx, fit in enumerate(fits):
        n, m = 4, 1

        options = {}
        if idx != 0: options['sharex'] = plots[idx - 1].plt

        plot = Plot(fit, figure.add_subplot(n, m, (m * idx + 1), **options))
        plot.id = fit_ids[idx]
        plots.append(plot)

    for idx, plot in enumerate(plots):
        plot.plot_data()
        plot.plot_fit()

        if idx == 2:
            plot.add_ylabel(False)
        else:
            plot.add_ylabel(True)

        plot.add_parameter_overlay()

    plots[-1].add_xlabel()
    matplotlib.pyplot.setp([ p.plt.get_xticklabels() for p in plots[0:3] ], visible=False)

    figure.savefig(os.path.join('build', 'plot_fits.eps'), transparent=True)
    plots[0].fit.save_info('build/plot_fits_info.tex', 'plotFitsInfo')
    Plot.close_figure(figure)