Histogram Quickstart
A histogram can be created from a collection of values.
ScottPlot.Plot myPlot = new();
// Create a histogram from a collection of values
double[] heights = SampleData.MaleHeights();
var hist = ScottPlot.Statistics.Histogram.WithBinCount(10, heights);
// Display the histogram as a bar plot
var barPlot = myPlot.Add.Bars(hist.Bins, hist.Counts);
// Size each bar slightly less than the width of a bin
foreach (var bar in barPlot.Bars)
{
bar.Size = hist.FirstBinSize * .8;
}
// Customize plot style
myPlot.Axes.Margins(bottom: 0);
myPlot.YLabel("Number of People");
myPlot.XLabel("Height (cm)");
myPlot.SavePng("demo.png", 400, 300);
This recipe is one of many in the Histogram category
