MCPcopy Index your code
hub / github.com/gonum/plot / NewHistogram

Function NewHistogram

plotter/histogram.go:54–65  ·  view source on GitHub ↗

NewHistogram returns a new histogram that represents the distribution of values using the given number of bins. Each y value is assumed to be the frequency count for the corresponding x. If the number of bins is non-positive than a reasonable default is used.

(xy XYer, n int)

Source from the content-addressed store, hash-verified

52// If the number of bins is non-positive than
53// a reasonable default is used.
54func NewHistogram(xy XYer, n int) (*Histogram, error) {
55 if n <= 0 {
56 return nil, errors.New("Histogram with non-positive number of bins")
57 }
58 bins, width := binPoints(xy, n)
59 return &Histogram{
60 Bins: bins,
61 Width: width,
62 FillColor: color.Gray{128},
63 LineStyle: DefaultLineStyle,
64 }, nil
65}
66
67// NewHist returns a new histogram, as in
68// NewHistogram, except that it accepts a Valuer

Callers 2

TestFillStyleFunction · 0.92
NewHistFunction · 0.85

Calls 1

binPointsFunction · 0.85

Tested by 1

TestFillStyleFunction · 0.74