Skip to main content

plots_to_make

Function plots_to_make 

Source
pub fn plots_to_make(
    format: Option<&str>,
    values: [Option<&str>; 3],
    shortcut: Option<usize>,
    plots: &[PlotCandidate],
    axes: &[Vec<String>],
) -> Result<PlotChoice>
Expand description

The plots to make for a format and up to three quantities: music21’s getPlotsToMake.

plots is every plot class, shortcut the index among them of the class a shortcut format names, where it is one, and axes the quantities of every axis class. Where no plot plots the quantities asked, the nearest plot is chosen with an axis class for each.

use music21::graph::find::{PlotCandidate, PlotChoice, plots_to_make};

let quantities = |names: &[&str]| names.iter().map(|n| n.to_string()).collect::<Vec<_>>();
let plots = [PlotCandidate {
    graph_type: "histogram".to_string(),
    axes: vec![('x', quantities(&["pitchSpace", "pitch"])), ('y', quantities(&["count"]))],
}];
let choice = plots_to_make(Some("pitch"), [None, None, None], None, &plots, &[])?;
assert_eq!(choice, PlotChoice::Plots(vec![0]));

§Errors

Quantities given with no format, or no plot classes to choose from.