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

Function ExampleQuartPlot

plotter/quartile_example_test.go:16–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14)
15
16func ExampleQuartPlot() {
17 rnd := rand.New(rand.NewPCG(1, 1))
18
19 // Create the example data.
20 n := 100
21 uniform := make(plotter.Values, n)
22 normal := make(plotter.Values, n)
23 expon := make(plotter.Values, n)
24 for i := range n {
25 uniform[i] = rnd.Float64()
26 normal[i] = rnd.NormFloat64()
27 expon[i] = rnd.ExpFloat64()
28 }
29
30 // Create the QuartPlots
31 qp1, err := plotter.NewQuartPlot(0, uniform)
32 if err != nil {
33 log.Panic(err)
34 }
35 qp2, err := plotter.NewQuartPlot(1, normal)
36 if err != nil {
37 log.Panic(err)
38 }
39 qp3, err := plotter.NewQuartPlot(2, expon)
40 if err != nil {
41 log.Panic(err)
42 }
43
44 // Create a vertical plot
45 p1 := plot.New()
46 p1.Title.Text = "Quartile Plot"
47 p1.Y.Label.Text = "plotter.Values"
48 p1.Add(qp1, qp2, qp3)
49
50 // Set the X axis of the plot to nominal with
51 // the given names for x=0, x=1 and x=2.
52 p1.NominalX("Uniform\nDistribution", "Normal\nDistribution",
53 "Exponential\nDistribution")
54
55 err = p1.Save(200, 200, "testdata/verticalQuartPlot.png")
56 if err != nil {
57 log.Panic(err)
58 }
59
60 // Create a horizontal plot
61 qp1.Horizontal = true
62 qp2.Horizontal = true
63 qp3.Horizontal = true
64
65 p2 := plot.New()
66 p2.Title.Text = "Quartile Plot"
67 p2.X.Label.Text = "plotter.Values"
68 p2.Add(qp1, qp2, qp3)
69
70 // Set the Y axis of the plot to nominal with
71 // the given names for y=0, y=1 and y=2.
72 p2.NominalY("Uniform\nDistribution", "Normal\nDistribution",
73 "Exponential\nDistribution")

Callers

nothing calls this directly

Calls 8

NewQuartPlotFunction · 0.92
NewFunction · 0.92
PointsFunction · 0.92
NewGlyphBoxesFunction · 0.92
NominalXMethod · 0.80
SaveMethod · 0.80
NominalYMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected