AddBoxPlots adds box plot plotters to a plot and sets the X axis of the plot to be nominal. The variadic arguments must be either strings or plotter.Valuers. Each valuer adds a box plot to the plot at the X location corresponding to the number of box plots added before it. If a plotter.Valuer is i
(plt *plot.Plot, width vg.Length, vs ...any)
| 96 | // If an error occurs then none of the plotters are added |
| 97 | // to the plot, and the error is returned. |
| 98 | func AddBoxPlots(plt *plot.Plot, width vg.Length, vs ...any) error { |
| 99 | var ps []plot.Plotter |
| 100 | var names []string |
| 101 | name := "" |
| 102 | for _, v := range vs { |
| 103 | switch t := v.(type) { |
| 104 | case string: |
| 105 | name = t |
| 106 | |
| 107 | case plotter.Valuer: |
| 108 | b, err := plotter.NewBoxPlot(width, float64(len(names)), t) |
| 109 | if err != nil { |
| 110 | return err |
| 111 | } |
| 112 | ps = append(ps, b) |
| 113 | names = append(names, name) |
| 114 | name = "" |
| 115 | |
| 116 | default: |
| 117 | panic(fmt.Sprintf("plotutil: AddBoxPlots handles strings and plotter.Valuers, got %T", t)) |
| 118 | } |
| 119 | } |
| 120 | plt.Add(ps...) |
| 121 | plt.NominalX(names...) |
| 122 | return nil |
| 123 | } |
| 124 | |
| 125 | // AddScatters adds Scatter plotters to a plot. |
| 126 | // The variadic arguments must be either strings |
nothing calls this directly
no test coverage detected