from chemparseplot.plot.structs import EnergyPath, BasePlotter, TwoDimPlot, XYData
from chemparseplot.plot.geomscan import plot_energy_paths
from chemparseplot.units import ureg
import numpy as np
import matplotlib.pyplot as plt

Overview

We plan to facilitate two kinds of plots:

  • One-shot paths on multiple files / data sources

  • Interactive plots

The reason why is simple, often one wishes to plot a couple of paths and add or remove paths which aren’t very useful.

One-shot multi-plot

path1 = EnergyPath('Path 1', np.linspace(0, 10, 30) * ureg.angstrom, np.random.uniform(-1, 0, 30) * ureg.hartree)
path2 = EnergyPath('Path 2', np.linspace(1, 9, 25) * ureg.angstrom, np.random.uniform(-0.5, 0.5, 25) * ureg.hartree)
plot_energy_paths([path1, path2], {'distance': 'angstrom', 'energy': 'hartree'}, colormap_fraction=0.4);
../_images/230e496769b3a5058401ecd586f1d7746903307b337b7849a8c19164a80275b0.png

Interactive plots

twodim_plot = TwoDimPlot()
twodim_plot.set_labels('Distance', 'Energy')
twodim_plot.set_units('angstrom', 'hartree')

# Add XYData
data1 = XYData('Path 1', np.linspace(0, 10, 30) * ureg.angstrom, np.random.uniform(-1, 0, 30) * ureg.hartree)
data2 = XYData('Path 2', np.linspace(1, 9, 25) * ureg.angstrom, np.random.uniform(-0.5, 0.5, 25) * ureg.hartree)
data3 = XYData('Path 3', np.linspace(1, 9, 25) * ureg.bohr, np.random.uniform(-0.5, 0.5, 25) * ureg.hartree)
twodim_plot.add_data(data1)
twodim_plot.add_data(data2)

twodim_plot.add_title("Two Dimensional Data Plot")
../_images/53d006803c9a7d719eb35965afbf6272015207b8348defda1c5bfbeb29c7f8fc.png
twodim_plot.set_units('angstrom', 'electron_volt')
twodim_plot.fig
../_images/d66606f3ef7052e949426da53278ecb3e3b0b6858963de9244b8d3b2fa84ae17.png
twodim_plot.add_data(data3)
twodim_plot.fig
../_images/7877cddcc82e8cc2f693ae05f35b64a8fca247cea01a615e095166ee42ed5192.png
max(data3.x.to("angstrom"))
4.762594898135798 angstrom