Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions palette/moreland/luminance.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,9 @@ func (l luminance) Palette(n int) palette.Palette {
l.SetMax(1)
}
delta := (l.max - l.min) / float64(n-1)
var v float64
c := make([]color.Color, n)
for i := range n {
v = l.min + float64(delta*float64(i))
v := min(l.min+float64(delta*float64(i)), l.max)
var err error
c[i], err = l.At(v)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions palette/moreland/luminance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,11 @@ func BenchmarkLuminance_At(b *testing.B) {
})
}
}

func TestIssue798Kindlmann(t *testing.T) {
// https://github.com/gonum/plot/issues/798
colors := Kindlmann()
colors.SetMin(0.3402859786606234)
colors.SetMax(15.322841335211892)
colors.Palette(15)
}
2 changes: 1 addition & 1 deletion palette/moreland/smooth.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (p smoothDiverging) Palette(n int) palette.Palette {
delta := (p.max - p.min) / float64(n-1)
c := make([]color.Color, n)
for i := range c {
v := p.min + float64(delta*float64(i))
v := min(p.min+float64(delta*float64(i)), p.max)
var err error
c[i], err = p.At(v)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions palette/moreland/smooth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,11 @@ func similar(a, b color.Color, tolerance float64) bool {
}
return true
}

func TestIssue798SmoothBlueRed(t *testing.T) {
// https://github.com/gonum/plot/issues/798
colors := SmoothBlueRed()
colors.SetMin(0.3402859786606234)
colors.SetMax(15.322841335211892)
colors.Palette(15)
}
Loading