import h_transport_materials as htm
import matplotlib.pyplot as plt

mat_to_colour = {
    htm.COPPER: "tab:orange",
    htm.CUCRZR: "tab:brown",
    htm.TUNGSTEN: "tab:grey",
}

fig, axs = plt.subplots(ncols=1, nrows=3, figsize=(6.4, 8), sharex=True)

# change the format of units in matplotlib
htm.ureg.mpl_formatter = "{:~P}"

for i, group in enumerate([htm.diffusivities, htm.solubilities, htm.permeabilities]):
    plt.sca(axs[i])
    filtered_group = group.filter(material=list(mat_to_colour.keys()))
    htm.plotting.plot(
        filtered_group, alpha=0.6, colour_by="material", key_to_colour=mat_to_colour
    )
    plt.yscale("log")
    plt.xlabel("")  # remove default xlabel

axs[0].get_legend().remove()
axs[1].get_legend().remove()

axs[0].set_title("Diffusivity")
axs[1].set_title("Solubility")
axs[2].set_title("Permeability")

plt.xlabel(f"Inverse temperature ({axs[-1].xaxis.get_units():~P})")
plt.show()