Skip to content

Commit

Permalink
plotter: check for negative Z-range for Contour
Browse files Browse the repository at this point in the history
  • Loading branch information
kortschak committed Oct 30, 2017
1 parent d2111bf commit 4f5600e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions plotter/contour.go
Expand Up @@ -50,6 +50,8 @@ type Contour struct {
// the 0.01, 0.05, 0.25, 0.5, 0.75, 0.95 and 0.99 quantiles.
// If g has Min and Max methods that return a float, those returned
// values are used to set the respective Contour fields.
// If the returned Contour is used when Min is greater than Max, the
// Plot method will panic.
func NewContour(g GridXYZ, levels []float64, p palette.Palette) *Contour {
var min, max float64
type minMaxer interface {
Expand Down Expand Up @@ -122,6 +124,10 @@ const naive = false

// Plot implements the Plot method of the plot.Plotter interface.
func (h *Contour) Plot(c draw.Canvas, plt *plot.Plot) {
if h.Min > h.Max {
panic("contour: negative Z range")
}

if naive {
h.naivePlot(c, plt)
return
Expand Down

0 comments on commit 4f5600e

Please sign in to comment.