import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt from ase.db import connect # connect to the database db = connect("dmc.db") # plot details mpl.rcParams["figure.figsize"] = (4,4) mpl.rcParams["text.usetex"] = True mpl.rcParams["font.family"] = "serif" mpl.rcParams["font.serif"] = "Computer Modern Roman" energies = [] error = [] products = [] for row in db.select(type="molecule", product=True): products.append(row.molecule) energies.append(row.reaction_free_energy) error.append(row.uncertainty) fig = plt.figure() ax = fig.add_subplot(111) # Barplot width = 0.8 locs = np.array(range(len(products)))+0.5 bar = ax.bar(locs, energies, yerr=np.array(error), width=width, edgecolor='none', color="teal", error_kw={'ecolor':"black", 'linewidth':1, 'capsize':1}) ax.set_xticks(np.arange(len(products))+1.4) ax.set_xticklabels(products, rotation='45') ax.set_ylim([-1.2, 3.2]) ax.set_ylabel(r'Reaction free energy (eV)') ax.set_xticks(np.array(range(len(products)))+0.5) ax.set_xticklabels(products) # Save figure fig.tight_layout() fig.savefig('reaction_energies', dpi=300)