calculate_ticks_in_units_of_pi
- calculate_ticks_in_units_of_pi(values: ndarray | DataArray, *, step_size: float = 0.5) tuple[Iterable[float], Iterable[str]] [source]
Calculate tick values and labels in units of Pi.
- Parameters:
values (np.ndarray | xr.DataArray) – Values which the ticks should be calculated for.
step_size (float) – Step size of the ticks in units of pi. Defaults to 0.5
- Returns:
Tick values and tick labels
- Return type:
tuple[Iterable[float], Iterable[str]]
Examples
If you have a case study that uses a
damped-oscillation
megacomplex you can plot thedamped_oscillation_phase
with y-tick in units of Pi by the following code given that the dataset is saved underdataset.nc
.import matplotlib.pyplot as plt from glotaran.io import load_dataset from pyglotaran_extras.plotting.utils import calculate_ticks_in_units_of_pi dataset = load_dataset("dataset.nc") fig, ax = plt.subplots(1, 1) damped_oscillation_phase = dataset["damped_oscillation_phase"].sel( damped_oscillation=["osc1"] ) damped_oscillation_phase.plot.line(x="spectral", ax=ax) ax.set_yticks( *calculate_ticks_in_units_of_pi(damped_oscillation_phase), rotation="horizontal" )