()
| 14 | ) |
| 15 | |
| 16 | func 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") |
nothing calls this directly
no test coverage detected