MCPcopy
hub / github.com/gonum/plot / NewBoxPlot

Function NewBoxPlot

plotter/boxplot.go:101–132  ·  view source on GitHub ↗

NewBoxPlot returns a new BoxPlot that represents the distribution of the given values. The style of the box plot is that used for Tukey's schematic plots in “Exploratory Data Analysis.” An error is returned if the boxplot is created with no values. The fence values are 1.5x the interquartile befo

(w vg.Length, loc float64, values Valuer)

Source from the content-addressed store, hash-verified

99// whiskers stretch) are the minimum and maximum
100// values that are not outside the fences.
101func NewBoxPlot(w vg.Length, loc float64, values Valuer) (*BoxPlot, error) {
102 if w < 0 {
103 return nil, errors.New("plotter: negative boxplot width")
104 }
105
106 b := new(BoxPlot)
107 var err error
108 if b.fiveStatPlot, err = newFiveStat(w, loc, values); err != nil {
109 return nil, err
110 }
111
112 b.Width = w
113 b.CapWidth = 3 * w / 4
114
115 b.GlyphStyle = DefaultGlyphStyle
116 b.BoxStyle = DefaultLineStyle
117 b.MedianStyle = DefaultLineStyle
118 b.WhiskerStyle = draw.LineStyle{
119 Width: vg.Points(0.5),
120 Dashes: []vg.Length{vg.Points(4), vg.Points(2)},
121 }
122
123 if len(b.Values) == 0 {
124 b.Width = 0
125 b.GlyphStyle.Radius = 0
126 b.BoxStyle.Width = 0
127 b.MedianStyle.Width = 0
128 b.WhiskerStyle.Width = 0
129 }
130
131 return b, nil
132}
133
134func newFiveStat(w vg.Length, loc float64, values Valuer) (fiveStatPlot, error) {
135 var b fiveStatPlot

Callers 2

ExampleBoxPlotFunction · 0.92
AddBoxPlotsFunction · 0.92

Calls 2

PointsFunction · 0.92
newFiveStatFunction · 0.85

Tested by 1

ExampleBoxPlotFunction · 0.74