pub fn histogram<V: ToString>(
data: &[V],
options: HistogramOptions,
) -> Result<Plot<BarplotGraphics>, HistogramError>Expand description
Constructs a histogram by binning data and delegating rendering to barplot.
§Examples
use unicode_plot::{HistogramOptions, histogram};
let mut options = HistogramOptions::default();
options.title = Some("Example Histogram".to_owned());
let data = vec![1.0, 1.5, 1.7, 2.0, 2.1, 2.9, 3.2, 3.8, 4.0, 4.1];
let plot = histogram(&data, options).unwrap();
let mut buf = Vec::new();
plot.render(&mut buf, false).unwrap();
let rendered = String::from_utf8(buf).unwrap();
assert!(rendered.contains("Example Histogram"));§Errors
Returns HistogramError::EmptyData for empty input,
HistogramError::InvalidBinCount when nbins is Some(0),
HistogramError::InvalidNumericValue if any value is non-finite, and
HistogramError::Barplot if barplot construction fails.