import utils import matplotlib.pyplot as plt from matplotlib.widgets import Slider def slideshow(): slabs, i_min, i_max = utils.load_slabs() f, axes = plt.subplots(2, 3, height_ratios=[10, 1]) for ax in axes.flat: ax.set_axis_off() ax, axfreq = axes[:,0] implot = ax.imshow(slabs[0]["data"], vmin=i_min, vmax=i_max) s = slabs[0] ax.set_title(f"Energy: {s["e"]}cm-1, total intensity: {s["total"]:.2e}") f.subplots_adjust(bottom=0.25) # Make a horizontal slider to control the frequency. freq_slider = Slider( ax=axfreq, label='Slab', valmin=0, valstep=1, valmax=len(slabs)-1, valinit=0, ) # The function to be called anytime a slider's value changes def update(val): s = slabs[val] implot.set_data(s["data"]) ax.set_title(f"Energy: {s["e"]}cm-1, total intensity: {s["total"]:.2e}") f.canvas.draw_idle() freq_slider.on_changed(update) ax_ch2, _ = axes[:,1] ax_ch2.imshow(slabs[5]["data"], vmin=i_min, vmax=i_max) s = slabs[5] ax_ch2.set_title(f"CH2 ({s["e"]} cm-1)") ax_ch3, _ = axes[:,2] ax_ch3.imshow(slabs[16]["data"], vmin=i_min, vmax=i_max) s = slabs[16] ax_ch3.set_title(f"CH3 ({s["e"]} cm-1)") plt.tight_layout() plt.show()