def plot_energy(args):
    #outfile = 'free_energy_{approx}.png'.format(**args.__dict__)
    outfile = (args.out_params + '.png').format(param='free_energy', **args.__dict__)
    pyplot.savefig(os.path.join(args.out_dir, outfile))
    pyplot.figure()
    pyplot.title(args.approx % 'Free energy for %s')
    pyplot.plot([-f for f in args.free_energy], label='Current run')
    pyplot.xlabel("iteration")
    pyplot.ylabel('-Free Energy')
    pyplot.savefig(os.path.join(args.out_dir, outfile))
    pyplot.close('all')

    if hasattr(args, 'prev_free_energy'):
        pyplot.figure()
        pyplot.title('Free energy for %s' % args.approx)
        pyplot.plot(range(len(args.prev_free_energy)), [-f for f in args.prev_free_energy], linestyle='-', label='Previous run')
        pyplot.plot(range(len(args.prev_free_energy), len(args.free_energy) + len(args.prev_free_energy)), [-f for f in args.free_energy], label='Current run')
        pyplot.legend(loc='lower left')
        pyplot.xlabel("iteration")
        pyplot.ylabel('-Free Energy')
        pyplot.savefig(os.path.join(args.out_dir, (args.out_params + 'vs_previous.png').format(param='free_energy', **args.__dict__)))
        pyplot.close('all')
dataset/ETHPy150Open uci-cbcl/tree-hmm/treehmm/plot.py/plot_energy/swapped operands of `%`