Add adds a Plotters to the plot. If the plotters implements DataRanger then the minimum and maximum values of the X and Y axes are changed if necessary to fit the range of the data. When drawing the plot, Plotters are drawn in the order in which they were added to the plot.
(ps ...Plotter)
| 122 | // When drawing the plot, Plotters are drawn in the |
| 123 | // order in which they were added to the plot. |
| 124 | func (p *Plot) Add(ps ...Plotter) { |
| 125 | for _, d := range ps { |
| 126 | if x, ok := d.(DataRanger); ok { |
| 127 | xmin, xmax, ymin, ymax := x.DataRange() |
| 128 | p.X.Min = math.Min(p.X.Min, xmin) |
| 129 | p.X.Max = math.Max(p.X.Max, xmax) |
| 130 | p.Y.Min = math.Min(p.Y.Min, ymin) |
| 131 | p.Y.Max = math.Max(p.Y.Max, ymax) |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | p.plotters = append(p.plotters, ps...) |
| 136 | } |
| 137 | |
| 138 | // Draw draws a plot to a draw.Canvas. |
| 139 | // |