Dual axis
This demo shows how to use dependent axes to create a secondary axis showing the same data in a different unit. In this case, the spectrum is drawn over the wavelength on the bottom -axis and over the corresponding photon energy (related through ) on the top -axis.
The data is a spectrogram of molecular oxygen, once measured by the author and a colleague with cavity-enhanced absorption spectroscopy.
#let (λ, intensity) = lq.load-txt(read("spectrum_o2.txt"), skip-rows: 2, delimiter: " ")
#let h = 6.62607015e-34
#let c = 299792458
#let e = 1.60217733e-19
#let k = 1e9 * h * c / e
#lq.diagram(
width: 10cm,
margin: 3%,
xaxis: (offset: 0, mirror: false),
xlabel: [Wavelength (nm)],
ylabel: [Relative intensity],
lq.plot(λ, intensity, mark: none),
lq.xaxis(
position: top,
label: [Energie (eV)],
offset: 0,
exponent: 0,
tick-distance: 5e-5,
functions: (λ => k / λ, E => k / E)
)
)