Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions align.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,13 +25,13 @@ func Align(plots [][]*Plot, t draw.Tiles, dc draw.Canvas) [][]draw.Canvas {
}

// Create the initial tiles.
for j := 0; j < t.Rows; j++ {
for j := range t.Rows {
if len(plots[j]) != t.Cols {
panic(fmt.Errorf("plot: plots row %d columns (%d) != tiles columns (%d)", j, len(plots[j]), t.Rows))
}

o[j] = make([]draw.Canvas, len(plots[j]))
for i := 0; i < t.Cols; i++ {
for i := range t.Cols {
o[j][i] = t.At(dc, i, j)
}
}
Expand Down
8 changes: 4 additions & 4 deletions align_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,9 +18,9 @@ import (
func ExampleAlign() {
const rows, cols = 4, 3
plots := make([][]*plot.Plot, rows)
for j := 0; j < rows; j++ {
for j := range rows {
plots[j] = make([]*plot.Plot, cols)
for i := 0; i < cols; i++ {
for i := range cols {
if i == 0 && j == 2 {
// This shows what happens when there are nil plots.
continue
Expand DownExpand Up@@ -70,8 +70,8 @@ func ExampleAlign() {
}

canvases := plot.Align(plots, t, dc)
for j := 0; j < rows; j++ {
for i := 0; i < cols; i++ {
for j := range rows {
for i := range cols {
if plots[j][i] != nil {
plots[j][i].Draw(canvases[j][i])
}
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/brewer.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,7 +125,7 @@ func GetPalette(typ PaletteType, name string, colors int) (palette.Palette, erro
)
switch typ {
case TypeAny:
var pt interface{}
var pt any
pt, nameOk = all[name]
if !nameOk {
break
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/palettes.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -4752,7 +4752,7 @@ var (
"YlOrBr": YlOrBr,
"YlOrRd": YlOrRd,
}
all=map[string]interface{}{
all=map[string]any{
"BrBG": BrBG,
"PiYG": PiYG,
"PRGn": PRGn,
Expand Down
4 changes: 2 additions & 2 deletions palette/moreland/example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,8 +53,8 @@ func Example() {
YOffset: -50,
Data: mat.NewDense(100, 100, nil),
}
for i := 0; i < 100; i++ {
for j := 0; j < 100; j++ {
for i := range 100 {
for j := range 100 {
x := float64(i-50) / 10
y := float64(j-50) / 10
v := math.Sin(x*x+y*y) / (x*x + y*y)
Expand Down
2 changes: 1 addition & 1 deletion palette/moreland/luminance.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -178,7 +178,7 @@ func (l luminance) Palette(n int) palette.Palette {
delta := (l.max - l.min) / float64(n-1)
var v float64
c := make([]color.Color, n)
for i := 0; i < n; i++ {
for i := range n {
v = l.min + float64(delta*float64(i))
var err error
c[i], err = l.At(v)
Expand Down
2 changes: 1 addition & 1 deletion plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,7 +165,7 @@ func ExampleBarChart_positiveNegative() {
data1 := make(plotter.Values, n)
data2 := make(plotter.Values, n)
net := make(plotter.XYs, n) // net = data1 + data2
for i := 0; i < n; i++ {
for i := range n {
data1[i] = rnd.Float64()*2 - 1
data2[i] = rnd.Float64()*2 - 1
net[i].X = data1[i] + data2[i]
Expand Down
2 changes: 1 addition & 1 deletion plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func ExampleBoxPlot() {
uniform := make(plotter.ValueLabels, n)
normal := make(plotter.ValueLabels, n)
expon := make(plotter.ValueLabels, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i].Value = rnd.Float64()
uniform[i].Label = fmt.Sprintf("%4.4f", uniform[i].Value)
normal[i].Value = rnd.NormFloat64()
Expand Down
4 changes: 2 additions & 2 deletions plotter/colorbar.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,7 +62,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: 1, Y: colors},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand All@@ -75,7 +75,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: colors, Y: 1},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand Down
6 changes: 3 additions & 3 deletions plotter/conrec.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
)

c, r := g.Dims()
for i := 0; i < c-1; i++ {
for j := 0; j < r-1; j++ {
for i := range c - 1 {
for j := range r - 1 {
dmin := math.Min(
math.Min(g.Z(i, j), g.Z(i, j+1)),
math.Min(g.Z(i+1, j), g.Z(i+1, j+1)),
Expand All@@ -92,7 +92,7 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
continue
}

for k := 0; k < len(heights); k++ {
for k := range heights {
if heights[k] < dmin || dmax < heights[k] {
continue
}
Expand Down
15 changes: 8 additions & 7 deletions plotter/contour.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ package plotter
import (
"image/color"
"math"
"slices"
"sort"

"gonum.org/v1/plot"
Expand DownExpand Up@@ -64,8 +65,8 @@ func NewContour(g GridXYZ, levels []float64, p palette.Palette) *Contour {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -98,8 +99,8 @@ var defaultQuantiles = []float64{0.01, 0.05, 0.25, 0.5, 0.75, 0.95, 0.99}
func quantilesR7(g GridXYZ, p []float64) []float64 {
c, r := g.Dims()
data := make([]float64, 0, c*r)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
if v := g.Z(i, j); !math.IsNaN(v) {
data = append(data, v)
}
Expand DownExpand Up@@ -267,8 +268,8 @@ func (h *Contour) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *Contour) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand DownExpand Up@@ -651,7 +652,7 @@ func (c *contour) exciseQuick(conts contourSet) {
conts[&contour{
z: c.z,
backward: path{wp[i]},
forward: append(path(nil), wp[i+1:j+1]...),
forward: slices.Clone(wp[i+1 : j+1]),
}] = struct{}{}
wp = append(wp[:i], wp[j:]...)
j = i + 1
Expand Down
5 changes: 3 additions & 2 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import (
"fmt"
"math"
"reflect"
"slices"
"sort"
"testing"

Expand DownExpand Up@@ -457,8 +458,8 @@ func TestExciseLoops(t *testing.T) {
for i, test := range loopTests {
gotSet := make(contourSet)
c := &contour{
backward: append(path(nil), test.c.backward...),
forward: append(path(nil), test.c.forward...),
backward: slices.Clone(test.c.backward),
forward: slices.Clone(test.c.forward),
}
gotSet[c] = struct{}{}
c.exciseLoops(gotSet, quick)
Expand Down
12 changes: 6 additions & 6 deletions plotter/field.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,8 +66,8 @@ type Field struct {
func NewField(f FieldXY) *Field {
max := math.Inf(-1)
c, r := f.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := f.Vector(i, j)
d := math.Hypot(v.X, v.Y)
if math.IsNaN(d) {
Expand All@@ -93,7 +93,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
trX, trY := plt.Transforms(&c)

cols, rows := f.FieldXY.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -111,7 +111,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
left = -(f.FieldXY.X(i) - f.FieldXY.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -200,8 +200,8 @@ func (f *Field) DataRange() (xmin, xmax, ymin, ymax float64) {
func (f *Field) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := f.FieldXY.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(f.FieldXY.X(i)),
Y: plt.Y.Norm(f.FieldXY.Y(j)),
Expand Down
16 changes: 8 additions & 8 deletions plotter/heat.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,8 +81,8 @@ func NewHeatMap(g GridXYZ, p palette.Palette) *HeatMap {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -120,8 +120,8 @@ func (h *HeatMap) plotRasterized(c draw.Canvas, plt *plot.Plot) {

pal := h.Palette.Colors()
ps := float64(len(pal)-1) / (h.Max - h.Min)
for i := 0; i < cols; i++ {
for j := 0; j < rows; j++ {
for i := range cols {
for j := range rows {
var col color.Color
switch v := h.GridXYZ.Z(i, j); {
case v < h.Min:
Expand DownExpand Up@@ -161,7 +161,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {

var pa vg.Path
cols, rows := h.GridXYZ.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -179,7 +179,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {
left = -(h.GridXYZ.X(i) - h.GridXYZ.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -258,8 +258,8 @@ func (h *HeatMap) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *HeatMap) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand Down
4 changes: 2 additions & 2 deletions plotter/histogram.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -186,7 +186,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
xmin, xmax := Range(XValues{xys})
if n <= 0 {
m := 0.0
for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
_, y := xys.XY(i)
m += math.Max(y, 1.0)
}
Expand All@@ -207,7 +207,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
bins[i].Max = xmin + float64(i+1)*w
}

for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
x, y := xys.XY(i)
bin := int((x - xmin) / w)
if x == xmax {
Expand Down
2 changes: 1 addition & 1 deletion plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,7 @@ func ExampleHistogram() {

n := 10000
vals := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
vals[i] = rnd.NormFloat64()
}

Expand Down
4 changes: 2 additions & 2 deletions plotter/image.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,13 +86,13 @@ func (img *Image) transformFor(p *plot.Plot) image.Image {
}
b := img.img.Bounds()
o := image.NewNRGBA64(b)
for c := 0; c < img.cols; c++ {
for c := range img.cols {
// Find the equivalent image column after applying axis transforms.
cTrans := int(p.X.Norm(img.x(c)) * float64(img.cols))
// Find the equivalent column of the previous image column after applying
// axis transforms.
cPrevTrans := int(p.X.Norm(img.x(maxInt(c-1, 0))) * float64(img.cols))
for r := 0; r < img.rows; r++ {
for r := range img.rows {
// Find the equivalent image row after applying axis transforms.
rTrans := int(p.Y.Norm(img.y(r)) * float64(img.rows))
// Find the equivalent row of the previous image row after applying
Expand Down
4 changes: 2 additions & 2 deletions plotter/plotter.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ type Valuer interface {
func Range(vs Valuer) (min, max float64) {
min = math.Inf(1)
max = math.Inf(-1)
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
v := vs.Value(i)
min = math.Min(min, v)
max = math.Max(max, v)
Expand DownExpand Up@@ -93,7 +93,7 @@ func CopyValues(vs Valuer) (Values, error) {
return nil, ErrNoData
}
cpy := make(Values, vs.Len())
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
cpy[i] = vs.Value(i)
if err := CheckFloats(cpy[i]); err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions plotter/polygon_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -121,9 +121,9 @@ func ExamplePolygon_hexagons() {
for i, xmin := range xstart {
ymin := ystart[i]
x := xmin
for ix := 0; ix < nx; ix++ {
for range nx {
y := ymin
for iy := 0; iy < ny; iy++ {
for range ny {
var poly *plotter.Polygon
poly, err = plotter.NewPolygon(hex(x, y, r))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ func ExampleQuartPlot() {
uniform := make(plotter.Values, n)
normal := make(plotter.Values, n)
expon := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i] = rnd.Float64()
normal[i] = rnd.NormFloat64()
expon[i] = rnd.ExpFloat64()
Expand Down
2 changes: 1 addition & 1 deletion plotter/rotation_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func Example_rotation() {
// Sin creates a sine curve.
sin := func(n int, xmax float64) plotter.XYs {
xy := make(plotter.XYs, n)
for i := 0; i < n; i++ {
for i := range n {
xy[i].X = xmax / float64(n) * float64(i)
xy[i].Y = math.Sin(xy[i].X) * 100
}
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions align.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,13 +25,13 @@ func Align(plots [][]*Plot, t draw.Tiles, dc draw.Canvas) [][]draw.Canvas {
}

// Create the initial tiles.
for j := 0; j < t.Rows; j++ {
for j := range t.Rows {
if len(plots[j]) != t.Cols {
panic(fmt.Errorf("plot: plots row %d columns (%d) != tiles columns (%d)", j, len(plots[j]), t.Rows))
}

o[j] = make([]draw.Canvas, len(plots[j]))
for i := 0; i < t.Cols; i++ {
for i := range t.Cols {
o[j][i] = t.At(dc, i, j)
}
}
Expand Down
8 changes: 4 additions & 4 deletions align_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,9 +18,9 @@ import (
func ExampleAlign() {
const rows, cols = 4, 3
plots := make([][]*plot.Plot, rows)
for j := 0; j < rows; j++ {
for j := range rows {
plots[j] = make([]*plot.Plot, cols)
for i := 0; i < cols; i++ {
for i := range cols {
if i == 0 && j == 2 {
// This shows what happens when there are nil plots.
continue
Expand DownExpand Up@@ -70,8 +70,8 @@ func ExampleAlign() {
}

canvases := plot.Align(plots, t, dc)
for j := 0; j < rows; j++ {
for i := 0; i < cols; i++ {
for j := range rows {
for i := range cols {
if plots[j][i] != nil {
plots[j][i].Draw(canvases[j][i])
}
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/brewer.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,7 +125,7 @@ func GetPalette(typ PaletteType, name string, colors int) (palette.Palette, erro
)
switch typ {
case TypeAny:
var pt interface{}
var pt any
pt, nameOk = all[name]
if !nameOk {
break
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/palettes.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -4752,7 +4752,7 @@ var (
"YlOrBr": YlOrBr,
"YlOrRd": YlOrRd,
}
all=map[string]interface{}{
all=map[string]any{
"BrBG": BrBG,
"PiYG": PiYG,
"PRGn": PRGn,
Expand Down
4 changes: 2 additions & 2 deletions palette/moreland/example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,8 +53,8 @@ func Example() {
YOffset: -50,
Data: mat.NewDense(100, 100, nil),
}
for i := 0; i < 100; i++ {
for j := 0; j < 100; j++ {
for i := range 100 {
for j := range 100 {
x := float64(i-50) / 10
y := float64(j-50) / 10
v := math.Sin(x*x+y*y) / (x*x + y*y)
Expand Down
2 changes: 1 addition & 1 deletion palette/moreland/luminance.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -178,7 +178,7 @@ func (l luminance) Palette(n int) palette.Palette {
delta := (l.max - l.min) / float64(n-1)
var v float64
c := make([]color.Color, n)
for i := 0; i < n; i++ {
for i := range n {
v = l.min + float64(delta*float64(i))
var err error
c[i], err = l.At(v)
Expand Down
2 changes: 1 addition & 1 deletion plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,7 +165,7 @@ func ExampleBarChart_positiveNegative() {
data1 := make(plotter.Values, n)
data2 := make(plotter.Values, n)
net := make(plotter.XYs, n) // net = data1 + data2
for i := 0; i < n; i++ {
for i := range n {
data1[i] = rnd.Float64()*2 - 1
data2[i] = rnd.Float64()*2 - 1
net[i].X = data1[i] + data2[i]
Expand Down
2 changes: 1 addition & 1 deletion plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func ExampleBoxPlot() {
uniform := make(plotter.ValueLabels, n)
normal := make(plotter.ValueLabels, n)
expon := make(plotter.ValueLabels, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i].Value = rnd.Float64()
uniform[i].Label = fmt.Sprintf("%4.4f", uniform[i].Value)
normal[i].Value = rnd.NormFloat64()
Expand Down
4 changes: 2 additions & 2 deletions plotter/colorbar.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,7 +62,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: 1, Y: colors},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand All@@ -75,7 +75,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: colors, Y: 1},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand Down
6 changes: 3 additions & 3 deletions plotter/conrec.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
)

c, r := g.Dims()
for i := 0; i < c-1; i++ {
for j := 0; j < r-1; j++ {
for i := range c - 1 {
for j := range r - 1 {
dmin := math.Min(
math.Min(g.Z(i, j), g.Z(i, j+1)),
math.Min(g.Z(i+1, j), g.Z(i+1, j+1)),
Expand All@@ -92,7 +92,7 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
continue
}

for k := 0; k < len(heights); k++ {
for k := range heights {
if heights[k] < dmin || dmax < heights[k] {
continue
}
Expand Down
15 changes: 8 additions & 7 deletions plotter/contour.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ package plotter
import (
"image/color"
"math"
"slices"
"sort"

"gonum.org/v1/plot"
Expand DownExpand Up@@ -64,8 +65,8 @@ func NewContour(g GridXYZ, levels []float64, p palette.Palette) *Contour {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -98,8 +99,8 @@ var defaultQuantiles = []float64{0.01, 0.05, 0.25, 0.5, 0.75, 0.95, 0.99}
func quantilesR7(g GridXYZ, p []float64) []float64 {
c, r := g.Dims()
data := make([]float64, 0, c*r)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
if v := g.Z(i, j); !math.IsNaN(v) {
data = append(data, v)
}
Expand DownExpand Up@@ -267,8 +268,8 @@ func (h *Contour) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *Contour) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand DownExpand Up@@ -651,7 +652,7 @@ func (c *contour) exciseQuick(conts contourSet) {
conts[&contour{
z: c.z,
backward: path{wp[i]},
forward: append(path(nil), wp[i+1:j+1]...),
forward: slices.Clone(wp[i+1 : j+1]),
}] = struct{}{}
wp = append(wp[:i], wp[j:]...)
j = i + 1
Expand Down
5 changes: 3 additions & 2 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import (
"fmt"
"math"
"reflect"
"slices"
"sort"
"testing"

Expand DownExpand Up@@ -457,8 +458,8 @@ func TestExciseLoops(t *testing.T) {
for i, test := range loopTests {
gotSet := make(contourSet)
c := &contour{
backward: append(path(nil), test.c.backward...),
forward: append(path(nil), test.c.forward...),
backward: slices.Clone(test.c.backward),
forward: slices.Clone(test.c.forward),
}
gotSet[c] = struct{}{}
c.exciseLoops(gotSet, quick)
Expand Down
12 changes: 6 additions & 6 deletions plotter/field.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,8 +66,8 @@ type Field struct {
func NewField(f FieldXY) *Field {
max := math.Inf(-1)
c, r := f.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := f.Vector(i, j)
d := math.Hypot(v.X, v.Y)
if math.IsNaN(d) {
Expand All@@ -93,7 +93,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
trX, trY := plt.Transforms(&c)

cols, rows := f.FieldXY.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -111,7 +111,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
left = -(f.FieldXY.X(i) - f.FieldXY.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -200,8 +200,8 @@ func (f *Field) DataRange() (xmin, xmax, ymin, ymax float64) {
func (f *Field) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := f.FieldXY.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(f.FieldXY.X(i)),
Y: plt.Y.Norm(f.FieldXY.Y(j)),
Expand Down
16 changes: 8 additions & 8 deletions plotter/heat.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,8 +81,8 @@ func NewHeatMap(g GridXYZ, p palette.Palette) *HeatMap {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -120,8 +120,8 @@ func (h *HeatMap) plotRasterized(c draw.Canvas, plt *plot.Plot) {

pal := h.Palette.Colors()
ps := float64(len(pal)-1) / (h.Max - h.Min)
for i := 0; i < cols; i++ {
for j := 0; j < rows; j++ {
for i := range cols {
for j := range rows {
var col color.Color
switch v := h.GridXYZ.Z(i, j); {
case v < h.Min:
Expand DownExpand Up@@ -161,7 +161,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {

var pa vg.Path
cols, rows := h.GridXYZ.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -179,7 +179,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {
left = -(h.GridXYZ.X(i) - h.GridXYZ.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -258,8 +258,8 @@ func (h *HeatMap) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *HeatMap) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand Down
4 changes: 2 additions & 2 deletions plotter/histogram.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -186,7 +186,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
xmin, xmax := Range(XValues{xys})
if n <= 0 {
m := 0.0
for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
_, y := xys.XY(i)
m += math.Max(y, 1.0)
}
Expand All@@ -207,7 +207,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
bins[i].Max = xmin + float64(i+1)*w
}

for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
x, y := xys.XY(i)
bin := int((x - xmin) / w)
if x == xmax {
Expand Down
2 changes: 1 addition & 1 deletion plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,7 @@ func ExampleHistogram() {

n := 10000
vals := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
vals[i] = rnd.NormFloat64()
}

Expand Down
4 changes: 2 additions & 2 deletions plotter/image.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,13 +86,13 @@ func (img *Image) transformFor(p *plot.Plot) image.Image {
}
b := img.img.Bounds()
o := image.NewNRGBA64(b)
for c := 0; c < img.cols; c++ {
for c := range img.cols {
// Find the equivalent image column after applying axis transforms.
cTrans := int(p.X.Norm(img.x(c)) * float64(img.cols))
// Find the equivalent column of the previous image column after applying
// axis transforms.
cPrevTrans := int(p.X.Norm(img.x(maxInt(c-1, 0))) * float64(img.cols))
for r := 0; r < img.rows; r++ {
for r := range img.rows {
// Find the equivalent image row after applying axis transforms.
rTrans := int(p.Y.Norm(img.y(r)) * float64(img.rows))
// Find the equivalent row of the previous image row after applying
Expand Down
4 changes: 2 additions & 2 deletions plotter/plotter.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ type Valuer interface {
func Range(vs Valuer) (min, max float64) {
min = math.Inf(1)
max = math.Inf(-1)
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
v := vs.Value(i)
min = math.Min(min, v)
max = math.Max(max, v)
Expand DownExpand Up@@ -93,7 +93,7 @@ func CopyValues(vs Valuer) (Values, error) {
return nil, ErrNoData
}
cpy := make(Values, vs.Len())
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
cpy[i] = vs.Value(i)
if err := CheckFloats(cpy[i]); err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions plotter/polygon_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -121,9 +121,9 @@ func ExamplePolygon_hexagons() {
for i, xmin := range xstart {
ymin := ystart[i]
x := xmin
for ix := 0; ix < nx; ix++ {
for range nx {
y := ymin
for iy := 0; iy < ny; iy++ {
for range ny {
var poly *plotter.Polygon
poly, err = plotter.NewPolygon(hex(x, y, r))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ func ExampleQuartPlot() {
uniform := make(plotter.Values, n)
normal := make(plotter.Values, n)
expon := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i] = rnd.Float64()
normal[i] = rnd.NormFloat64()
expon[i] = rnd.ExpFloat64()
Expand Down
2 changes: 1 addition & 1 deletion plotter/rotation_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func Example_rotation() {
// Sin creates a sine curve.
sin := func(n int, xmax float64) plotter.XYs {
xy := make(plotter.XYs, n)
for i := 0; i < n; i++ {
for i := range n {
xy[i].X = xmax / float64(n) * float64(i)
xy[i].Y = math.Sin(xy[i].X) * 100
}
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions align.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,13 +25,13 @@ func Align(plots [][]*Plot, t draw.Tiles, dc draw.Canvas) [][]draw.Canvas {
}

// Create the initial tiles.
for j := 0; j < t.Rows; j++ {
for j := range t.Rows {
if len(plots[j]) != t.Cols {
panic(fmt.Errorf("plot: plots row %d columns (%d) != tiles columns (%d)", j, len(plots[j]), t.Rows))
}

o[j] = make([]draw.Canvas, len(plots[j]))
for i := 0; i < t.Cols; i++ {
for i := range t.Cols {
o[j][i] = t.At(dc, i, j)
}
}
Expand Down
8 changes: 4 additions & 4 deletions align_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,9 +18,9 @@ import (
func ExampleAlign() {
const rows, cols = 4, 3
plots := make([][]*plot.Plot, rows)
for j := 0; j < rows; j++ {
for j := range rows {
plots[j] = make([]*plot.Plot, cols)
for i := 0; i < cols; i++ {
for i := range cols {
if i == 0 && j == 2 {
// This shows what happens when there are nil plots.
continue
Expand DownExpand Up@@ -70,8 +70,8 @@ func ExampleAlign() {
}

canvases := plot.Align(plots, t, dc)
for j := 0; j < rows; j++ {
for i := 0; i < cols; i++ {
for j := range rows {
for i := range cols {
if plots[j][i] != nil {
plots[j][i].Draw(canvases[j][i])
}
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/brewer.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,7 +125,7 @@ func GetPalette(typ PaletteType, name string, colors int) (palette.Palette, erro
)
switch typ {
case TypeAny:
var pt interface{}
var pt any
pt, nameOk = all[name]
if !nameOk {
break
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/palettes.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -4752,7 +4752,7 @@ var (
"YlOrBr": YlOrBr,
"YlOrRd": YlOrRd,
}
all=map[string]interface{}{
all=map[string]any{
"BrBG": BrBG,
"PiYG": PiYG,
"PRGn": PRGn,
Expand Down
4 changes: 2 additions & 2 deletions palette/moreland/example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,8 +53,8 @@ func Example() {
YOffset: -50,
Data: mat.NewDense(100, 100, nil),
}
for i := 0; i < 100; i++ {
for j := 0; j < 100; j++ {
for i := range 100 {
for j := range 100 {
x := float64(i-50) / 10
y := float64(j-50) / 10
v := math.Sin(x*x+y*y) / (x*x + y*y)
Expand Down
2 changes: 1 addition & 1 deletion palette/moreland/luminance.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -178,7 +178,7 @@ func (l luminance) Palette(n int) palette.Palette {
delta := (l.max - l.min) / float64(n-1)
var v float64
c := make([]color.Color, n)
for i := 0; i < n; i++ {
for i := range n {
v = l.min + float64(delta*float64(i))
var err error
c[i], err = l.At(v)
Expand Down
2 changes: 1 addition & 1 deletion plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,7 +165,7 @@ func ExampleBarChart_positiveNegative() {
data1 := make(plotter.Values, n)
data2 := make(plotter.Values, n)
net := make(plotter.XYs, n) // net = data1 + data2
for i := 0; i < n; i++ {
for i := range n {
data1[i] = rnd.Float64()*2 - 1
data2[i] = rnd.Float64()*2 - 1
net[i].X = data1[i] + data2[i]
Expand Down
2 changes: 1 addition & 1 deletion plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func ExampleBoxPlot() {
uniform := make(plotter.ValueLabels, n)
normal := make(plotter.ValueLabels, n)
expon := make(plotter.ValueLabels, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i].Value = rnd.Float64()
uniform[i].Label = fmt.Sprintf("%4.4f", uniform[i].Value)
normal[i].Value = rnd.NormFloat64()
Expand Down
4 changes: 2 additions & 2 deletions plotter/colorbar.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,7 +62,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: 1, Y: colors},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand All@@ -75,7 +75,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: colors, Y: 1},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand Down
6 changes: 3 additions & 3 deletions plotter/conrec.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
)

c, r := g.Dims()
for i := 0; i < c-1; i++ {
for j := 0; j < r-1; j++ {
for i := range c - 1 {
for j := range r - 1 {
dmin := math.Min(
math.Min(g.Z(i, j), g.Z(i, j+1)),
math.Min(g.Z(i+1, j), g.Z(i+1, j+1)),
Expand All@@ -92,7 +92,7 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
continue
}

for k := 0; k < len(heights); k++ {
for k := range heights {
if heights[k] < dmin || dmax < heights[k] {
continue
}
Expand Down
15 changes: 8 additions & 7 deletions plotter/contour.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ package plotter
import (
"image/color"
"math"
"slices"
"sort"

"gonum.org/v1/plot"
Expand DownExpand Up@@ -64,8 +65,8 @@ func NewContour(g GridXYZ, levels []float64, p palette.Palette) *Contour {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -98,8 +99,8 @@ var defaultQuantiles = []float64{0.01, 0.05, 0.25, 0.5, 0.75, 0.95, 0.99}
func quantilesR7(g GridXYZ, p []float64) []float64 {
c, r := g.Dims()
data := make([]float64, 0, c*r)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
if v := g.Z(i, j); !math.IsNaN(v) {
data = append(data, v)
}
Expand DownExpand Up@@ -267,8 +268,8 @@ func (h *Contour) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *Contour) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand DownExpand Up@@ -651,7 +652,7 @@ func (c *contour) exciseQuick(conts contourSet) {
conts[&contour{
z: c.z,
backward: path{wp[i]},
forward: append(path(nil), wp[i+1:j+1]...),
forward: slices.Clone(wp[i+1 : j+1]),
}] = struct{}{}
wp = append(wp[:i], wp[j:]...)
j = i + 1
Expand Down
5 changes: 3 additions & 2 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import (
"fmt"
"math"
"reflect"
"slices"
"sort"
"testing"

Expand DownExpand Up@@ -457,8 +458,8 @@ func TestExciseLoops(t *testing.T) {
for i, test := range loopTests {
gotSet := make(contourSet)
c := &contour{
backward: append(path(nil), test.c.backward...),
forward: append(path(nil), test.c.forward...),
backward: slices.Clone(test.c.backward),
forward: slices.Clone(test.c.forward),
}
gotSet[c] = struct{}{}
c.exciseLoops(gotSet, quick)
Expand Down
12 changes: 6 additions & 6 deletions plotter/field.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,8 +66,8 @@ type Field struct {
func NewField(f FieldXY) *Field {
max := math.Inf(-1)
c, r := f.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := f.Vector(i, j)
d := math.Hypot(v.X, v.Y)
if math.IsNaN(d) {
Expand All@@ -93,7 +93,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
trX, trY := plt.Transforms(&c)

cols, rows := f.FieldXY.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -111,7 +111,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
left = -(f.FieldXY.X(i) - f.FieldXY.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -200,8 +200,8 @@ func (f *Field) DataRange() (xmin, xmax, ymin, ymax float64) {
func (f *Field) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := f.FieldXY.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(f.FieldXY.X(i)),
Y: plt.Y.Norm(f.FieldXY.Y(j)),
Expand Down
16 changes: 8 additions & 8 deletions plotter/heat.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,8 +81,8 @@ func NewHeatMap(g GridXYZ, p palette.Palette) *HeatMap {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -120,8 +120,8 @@ func (h *HeatMap) plotRasterized(c draw.Canvas, plt *plot.Plot) {

pal := h.Palette.Colors()
ps := float64(len(pal)-1) / (h.Max - h.Min)
for i := 0; i < cols; i++ {
for j := 0; j < rows; j++ {
for i := range cols {
for j := range rows {
var col color.Color
switch v := h.GridXYZ.Z(i, j); {
case v < h.Min:
Expand DownExpand Up@@ -161,7 +161,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {

var pa vg.Path
cols, rows := h.GridXYZ.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -179,7 +179,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {
left = -(h.GridXYZ.X(i) - h.GridXYZ.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -258,8 +258,8 @@ func (h *HeatMap) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *HeatMap) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand Down
4 changes: 2 additions & 2 deletions plotter/histogram.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -186,7 +186,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
xmin, xmax := Range(XValues{xys})
if n <= 0 {
m := 0.0
for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
_, y := xys.XY(i)
m += math.Max(y, 1.0)
}
Expand All@@ -207,7 +207,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
bins[i].Max = xmin + float64(i+1)*w
}

for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
x, y := xys.XY(i)
bin := int((x - xmin) / w)
if x == xmax {
Expand Down
2 changes: 1 addition & 1 deletion plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,7 @@ func ExampleHistogram() {

n := 10000
vals := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
vals[i] = rnd.NormFloat64()
}

Expand Down
4 changes: 2 additions & 2 deletions plotter/image.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,13 +86,13 @@ func (img *Image) transformFor(p *plot.Plot) image.Image {
}
b := img.img.Bounds()
o := image.NewNRGBA64(b)
for c := 0; c < img.cols; c++ {
for c := range img.cols {
// Find the equivalent image column after applying axis transforms.
cTrans := int(p.X.Norm(img.x(c)) * float64(img.cols))
// Find the equivalent column of the previous image column after applying
// axis transforms.
cPrevTrans := int(p.X.Norm(img.x(maxInt(c-1, 0))) * float64(img.cols))
for r := 0; r < img.rows; r++ {
for r := range img.rows {
// Find the equivalent image row after applying axis transforms.
rTrans := int(p.Y.Norm(img.y(r)) * float64(img.rows))
// Find the equivalent row of the previous image row after applying
Expand Down
4 changes: 2 additions & 2 deletions plotter/plotter.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ type Valuer interface {
func Range(vs Valuer) (min, max float64) {
min = math.Inf(1)
max = math.Inf(-1)
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
v := vs.Value(i)
min = math.Min(min, v)
max = math.Max(max, v)
Expand DownExpand Up@@ -93,7 +93,7 @@ func CopyValues(vs Valuer) (Values, error) {
return nil, ErrNoData
}
cpy := make(Values, vs.Len())
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
cpy[i] = vs.Value(i)
if err := CheckFloats(cpy[i]); err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions plotter/polygon_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -121,9 +121,9 @@ func ExamplePolygon_hexagons() {
for i, xmin := range xstart {
ymin := ystart[i]
x := xmin
for ix := 0; ix < nx; ix++ {
for range nx {
y := ymin
for iy := 0; iy < ny; iy++ {
for range ny {
var poly *plotter.Polygon
poly, err = plotter.NewPolygon(hex(x, y, r))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ func ExampleQuartPlot() {
uniform := make(plotter.Values, n)
normal := make(plotter.Values, n)
expon := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i] = rnd.Float64()
normal[i] = rnd.NormFloat64()
expon[i] = rnd.ExpFloat64()
Expand Down
2 changes: 1 addition & 1 deletion plotter/rotation_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func Example_rotation() {
// Sin creates a sine curve.
sin := func(n int, xmax float64) plotter.XYs {
xy := make(plotter.XYs, n)
for i := 0; i < n; i++ {
for i := range n {
xy[i].X = xmax / float64(n) * float64(i)
xy[i].Y = math.Sin(xy[i].X) * 100
}
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions align.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,13 +25,13 @@ func Align(plots [][]*Plot, t draw.Tiles, dc draw.Canvas) [][]draw.Canvas {
}

// Create the initial tiles.
for j := 0; j < t.Rows; j++ {
for j := range t.Rows {
if len(plots[j]) != t.Cols {
panic(fmt.Errorf("plot: plots row %d columns (%d) != tiles columns (%d)", j, len(plots[j]), t.Rows))
}

o[j] = make([]draw.Canvas, len(plots[j]))
for i := 0; i < t.Cols; i++ {
for i := range t.Cols {
o[j][i] = t.At(dc, i, j)
}
}
Expand Down
8 changes: 4 additions & 4 deletions align_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,9 +18,9 @@ import (
func ExampleAlign() {
const rows, cols = 4, 3
plots := make([][]*plot.Plot, rows)
for j := 0; j < rows; j++ {
for j := range rows {
plots[j] = make([]*plot.Plot, cols)
for i := 0; i < cols; i++ {
for i := range cols {
if i == 0 && j == 2 {
// This shows what happens when there are nil plots.
continue
Expand DownExpand Up@@ -70,8 +70,8 @@ func ExampleAlign() {
}

canvases := plot.Align(plots, t, dc)
for j := 0; j < rows; j++ {
for i := 0; i < cols; i++ {
for j := range rows {
for i := range cols {
if plots[j][i] != nil {
plots[j][i].Draw(canvases[j][i])
}
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/brewer.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,7 +125,7 @@ func GetPalette(typ PaletteType, name string, colors int) (palette.Palette, erro
)
switch typ {
case TypeAny:
var pt interface{}
var pt any
pt, nameOk = all[name]
if !nameOk {
break
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/palettes.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -4752,7 +4752,7 @@ var (
"YlOrBr": YlOrBr,
"YlOrRd": YlOrRd,
}
all=map[string]interface{}{
all=map[string]any{
"BrBG": BrBG,
"PiYG": PiYG,
"PRGn": PRGn,
Expand Down
4 changes: 2 additions & 2 deletions palette/moreland/example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,8 +53,8 @@ func Example() {
YOffset: -50,
Data: mat.NewDense(100, 100, nil),
}
for i := 0; i < 100; i++ {
for j := 0; j < 100; j++ {
for i := range 100 {
for j := range 100 {
x := float64(i-50) / 10
y := float64(j-50) / 10
v := math.Sin(x*x+y*y) / (x*x + y*y)
Expand Down
2 changes: 1 addition & 1 deletion palette/moreland/luminance.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -178,7 +178,7 @@ func (l luminance) Palette(n int) palette.Palette {
delta := (l.max - l.min) / float64(n-1)
var v float64
c := make([]color.Color, n)
for i := 0; i < n; i++ {
for i := range n {
v = l.min + float64(delta*float64(i))
var err error
c[i], err = l.At(v)
Expand Down
2 changes: 1 addition & 1 deletion plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,7 +165,7 @@ func ExampleBarChart_positiveNegative() {
data1 := make(plotter.Values, n)
data2 := make(plotter.Values, n)
net := make(plotter.XYs, n) // net = data1 + data2
for i := 0; i < n; i++ {
for i := range n {
data1[i] = rnd.Float64()*2 - 1
data2[i] = rnd.Float64()*2 - 1
net[i].X = data1[i] + data2[i]
Expand Down
2 changes: 1 addition & 1 deletion plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func ExampleBoxPlot() {
uniform := make(plotter.ValueLabels, n)
normal := make(plotter.ValueLabels, n)
expon := make(plotter.ValueLabels, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i].Value = rnd.Float64()
uniform[i].Label = fmt.Sprintf("%4.4f", uniform[i].Value)
normal[i].Value = rnd.NormFloat64()
Expand Down
4 changes: 2 additions & 2 deletions plotter/colorbar.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,7 +62,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: 1, Y: colors},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand All@@ -75,7 +75,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: colors, Y: 1},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand Down
6 changes: 3 additions & 3 deletions plotter/conrec.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
)

c, r := g.Dims()
for i := 0; i < c-1; i++ {
for j := 0; j < r-1; j++ {
for i := range c - 1 {
for j := range r - 1 {
dmin := math.Min(
math.Min(g.Z(i, j), g.Z(i, j+1)),
math.Min(g.Z(i+1, j), g.Z(i+1, j+1)),
Expand All@@ -92,7 +92,7 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
continue
}

for k := 0; k < len(heights); k++ {
for k := range heights {
if heights[k] < dmin || dmax < heights[k] {
continue
}
Expand Down
15 changes: 8 additions & 7 deletions plotter/contour.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ package plotter
import (
"image/color"
"math"
"slices"
"sort"

"gonum.org/v1/plot"
Expand DownExpand Up@@ -64,8 +65,8 @@ func NewContour(g GridXYZ, levels []float64, p palette.Palette) *Contour {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -98,8 +99,8 @@ var defaultQuantiles = []float64{0.01, 0.05, 0.25, 0.5, 0.75, 0.95, 0.99}
func quantilesR7(g GridXYZ, p []float64) []float64 {
c, r := g.Dims()
data := make([]float64, 0, c*r)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
if v := g.Z(i, j); !math.IsNaN(v) {
data = append(data, v)
}
Expand DownExpand Up@@ -267,8 +268,8 @@ func (h *Contour) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *Contour) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand DownExpand Up@@ -651,7 +652,7 @@ func (c *contour) exciseQuick(conts contourSet) {
conts[&contour{
z: c.z,
backward: path{wp[i]},
forward: append(path(nil), wp[i+1:j+1]...),
forward: slices.Clone(wp[i+1 : j+1]),
}] = struct{}{}
wp = append(wp[:i], wp[j:]...)
j = i + 1
Expand Down
5 changes: 3 additions & 2 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import (
"fmt"
"math"
"reflect"
"slices"
"sort"
"testing"

Expand DownExpand Up@@ -457,8 +458,8 @@ func TestExciseLoops(t *testing.T) {
for i, test := range loopTests {
gotSet := make(contourSet)
c := &contour{
backward: append(path(nil), test.c.backward...),
forward: append(path(nil), test.c.forward...),
backward: slices.Clone(test.c.backward),
forward: slices.Clone(test.c.forward),
}
gotSet[c] = struct{}{}
c.exciseLoops(gotSet, quick)
Expand Down
12 changes: 6 additions & 6 deletions plotter/field.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,8 +66,8 @@ type Field struct {
func NewField(f FieldXY) *Field {
max := math.Inf(-1)
c, r := f.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := f.Vector(i, j)
d := math.Hypot(v.X, v.Y)
if math.IsNaN(d) {
Expand All@@ -93,7 +93,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
trX, trY := plt.Transforms(&c)

cols, rows := f.FieldXY.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -111,7 +111,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
left = -(f.FieldXY.X(i) - f.FieldXY.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -200,8 +200,8 @@ func (f *Field) DataRange() (xmin, xmax, ymin, ymax float64) {
func (f *Field) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := f.FieldXY.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(f.FieldXY.X(i)),
Y: plt.Y.Norm(f.FieldXY.Y(j)),
Expand Down
16 changes: 8 additions & 8 deletions plotter/heat.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,8 +81,8 @@ func NewHeatMap(g GridXYZ, p palette.Palette) *HeatMap {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -120,8 +120,8 @@ func (h *HeatMap) plotRasterized(c draw.Canvas, plt *plot.Plot) {

pal := h.Palette.Colors()
ps := float64(len(pal)-1) / (h.Max - h.Min)
for i := 0; i < cols; i++ {
for j := 0; j < rows; j++ {
for i := range cols {
for j := range rows {
var col color.Color
switch v := h.GridXYZ.Z(i, j); {
case v < h.Min:
Expand DownExpand Up@@ -161,7 +161,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {

var pa vg.Path
cols, rows := h.GridXYZ.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -179,7 +179,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {
left = -(h.GridXYZ.X(i) - h.GridXYZ.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -258,8 +258,8 @@ func (h *HeatMap) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *HeatMap) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand Down
4 changes: 2 additions & 2 deletions plotter/histogram.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -186,7 +186,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
xmin, xmax := Range(XValues{xys})
if n <= 0 {
m := 0.0
for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
_, y := xys.XY(i)
m += math.Max(y, 1.0)
}
Expand All@@ -207,7 +207,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
bins[i].Max = xmin + float64(i+1)*w
}

for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
x, y := xys.XY(i)
bin := int((x - xmin) / w)
if x == xmax {
Expand Down
2 changes: 1 addition & 1 deletion plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,7 @@ func ExampleHistogram() {

n := 10000
vals := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
vals[i] = rnd.NormFloat64()
}

Expand Down
4 changes: 2 additions & 2 deletions plotter/image.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,13 +86,13 @@ func (img *Image) transformFor(p *plot.Plot) image.Image {
}
b := img.img.Bounds()
o := image.NewNRGBA64(b)
for c := 0; c < img.cols; c++ {
for c := range img.cols {
// Find the equivalent image column after applying axis transforms.
cTrans := int(p.X.Norm(img.x(c)) * float64(img.cols))
// Find the equivalent column of the previous image column after applying
// axis transforms.
cPrevTrans := int(p.X.Norm(img.x(maxInt(c-1, 0))) * float64(img.cols))
for r := 0; r < img.rows; r++ {
for r := range img.rows {
// Find the equivalent image row after applying axis transforms.
rTrans := int(p.Y.Norm(img.y(r)) * float64(img.rows))
// Find the equivalent row of the previous image row after applying
Expand Down
4 changes: 2 additions & 2 deletions plotter/plotter.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ type Valuer interface {
func Range(vs Valuer) (min, max float64) {
min = math.Inf(1)
max = math.Inf(-1)
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
v := vs.Value(i)
min = math.Min(min, v)
max = math.Max(max, v)
Expand DownExpand Up@@ -93,7 +93,7 @@ func CopyValues(vs Valuer) (Values, error) {
return nil, ErrNoData
}
cpy := make(Values, vs.Len())
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
cpy[i] = vs.Value(i)
if err := CheckFloats(cpy[i]); err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions plotter/polygon_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -121,9 +121,9 @@ func ExamplePolygon_hexagons() {
for i, xmin := range xstart {
ymin := ystart[i]
x := xmin
for ix := 0; ix < nx; ix++ {
for range nx {
y := ymin
for iy := 0; iy < ny; iy++ {
for range ny {
var poly *plotter.Polygon
poly, err = plotter.NewPolygon(hex(x, y, r))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ func ExampleQuartPlot() {
uniform := make(plotter.Values, n)
normal := make(plotter.Values, n)
expon := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i] = rnd.Float64()
normal[i] = rnd.NormFloat64()
expon[i] = rnd.ExpFloat64()
Expand Down
2 changes: 1 addition & 1 deletion plotter/rotation_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func Example_rotation() {
// Sin creates a sine curve.
sin := func(n int, xmax float64) plotter.XYs {
xy := make(plotter.XYs, n)
for i := 0; i < n; i++ {
for i := range n {
xy[i].X = xmax / float64(n) * float64(i)
xy[i].Y = math.Sin(xy[i].X) * 100
}
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions align.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,13 +25,13 @@ func Align(plots [][]*Plot, t draw.Tiles, dc draw.Canvas) [][]draw.Canvas {
}

// Create the initial tiles.
for j := 0; j < t.Rows; j++ {
for j := range t.Rows {
if len(plots[j]) != t.Cols {
panic(fmt.Errorf("plot: plots row %d columns (%d) != tiles columns (%d)", j, len(plots[j]), t.Rows))
}

o[j] = make([]draw.Canvas, len(plots[j]))
for i := 0; i < t.Cols; i++ {
for i := range t.Cols {
o[j][i] = t.At(dc, i, j)
}
}
Expand Down
8 changes: 4 additions & 4 deletions align_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,9 +18,9 @@ import (
func ExampleAlign() {
const rows, cols = 4, 3
plots := make([][]*plot.Plot, rows)
for j := 0; j < rows; j++ {
for j := range rows {
plots[j] = make([]*plot.Plot, cols)
for i := 0; i < cols; i++ {
for i := range cols {
if i == 0 && j == 2 {
// This shows what happens when there are nil plots.
continue
Expand DownExpand Up@@ -70,8 +70,8 @@ func ExampleAlign() {
}

canvases := plot.Align(plots, t, dc)
for j := 0; j < rows; j++ {
for i := 0; i < cols; i++ {
for j := range rows {
for i := range cols {
if plots[j][i] != nil {
plots[j][i].Draw(canvases[j][i])
}
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/brewer.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,7 +125,7 @@ func GetPalette(typ PaletteType, name string, colors int) (palette.Palette, erro
)
switch typ {
case TypeAny:
var pt interface{}
var pt any
pt, nameOk = all[name]
if !nameOk {
break
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/palettes.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -4752,7 +4752,7 @@ var (
"YlOrBr": YlOrBr,
"YlOrRd": YlOrRd,
}
all=map[string]interface{}{
all=map[string]any{
"BrBG": BrBG,
"PiYG": PiYG,
"PRGn": PRGn,
Expand Down
4 changes: 2 additions & 2 deletions palette/moreland/example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,8 +53,8 @@ func Example() {
YOffset: -50,
Data: mat.NewDense(100, 100, nil),
}
for i := 0; i < 100; i++ {
for j := 0; j < 100; j++ {
for i := range 100 {
for j := range 100 {
x := float64(i-50) / 10
y := float64(j-50) / 10
v := math.Sin(x*x+y*y) / (x*x + y*y)
Expand Down
2 changes: 1 addition & 1 deletion palette/moreland/luminance.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -178,7 +178,7 @@ func (l luminance) Palette(n int) palette.Palette {
delta := (l.max - l.min) / float64(n-1)
var v float64
c := make([]color.Color, n)
for i := 0; i < n; i++ {
for i := range n {
v = l.min + float64(delta*float64(i))
var err error
c[i], err = l.At(v)
Expand Down
2 changes: 1 addition & 1 deletion plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,7 +165,7 @@ func ExampleBarChart_positiveNegative() {
data1 := make(plotter.Values, n)
data2 := make(plotter.Values, n)
net := make(plotter.XYs, n) // net = data1 + data2
for i := 0; i < n; i++ {
for i := range n {
data1[i] = rnd.Float64()*2 - 1
data2[i] = rnd.Float64()*2 - 1
net[i].X = data1[i] + data2[i]
Expand Down
2 changes: 1 addition & 1 deletion plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func ExampleBoxPlot() {
uniform := make(plotter.ValueLabels, n)
normal := make(plotter.ValueLabels, n)
expon := make(plotter.ValueLabels, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i].Value = rnd.Float64()
uniform[i].Label = fmt.Sprintf("%4.4f", uniform[i].Value)
normal[i].Value = rnd.NormFloat64()
Expand Down
4 changes: 2 additions & 2 deletions plotter/colorbar.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,7 +62,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: 1, Y: colors},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand All@@ -75,7 +75,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: colors, Y: 1},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand Down
6 changes: 3 additions & 3 deletions plotter/conrec.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
)

c, r := g.Dims()
for i := 0; i < c-1; i++ {
for j := 0; j < r-1; j++ {
for i := range c - 1 {
for j := range r - 1 {
dmin := math.Min(
math.Min(g.Z(i, j), g.Z(i, j+1)),
math.Min(g.Z(i+1, j), g.Z(i+1, j+1)),
Expand All@@ -92,7 +92,7 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
continue
}

for k := 0; k < len(heights); k++ {
for k := range heights {
if heights[k] < dmin || dmax < heights[k] {
continue
}
Expand Down
15 changes: 8 additions & 7 deletions plotter/contour.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ package plotter
import (
"image/color"
"math"
"slices"
"sort"

"gonum.org/v1/plot"
Expand DownExpand Up@@ -64,8 +65,8 @@ func NewContour(g GridXYZ, levels []float64, p palette.Palette) *Contour {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -98,8 +99,8 @@ var defaultQuantiles = []float64{0.01, 0.05, 0.25, 0.5, 0.75, 0.95, 0.99}
func quantilesR7(g GridXYZ, p []float64) []float64 {
c, r := g.Dims()
data := make([]float64, 0, c*r)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
if v := g.Z(i, j); !math.IsNaN(v) {
data = append(data, v)
}
Expand DownExpand Up@@ -267,8 +268,8 @@ func (h *Contour) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *Contour) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand DownExpand Up@@ -651,7 +652,7 @@ func (c *contour) exciseQuick(conts contourSet) {
conts[&contour{
z: c.z,
backward: path{wp[i]},
forward: append(path(nil), wp[i+1:j+1]...),
forward: slices.Clone(wp[i+1 : j+1]),
}] = struct{}{}
wp = append(wp[:i], wp[j:]...)
j = i + 1
Expand Down
5 changes: 3 additions & 2 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import (
"fmt"
"math"
"reflect"
"slices"
"sort"
"testing"

Expand DownExpand Up@@ -457,8 +458,8 @@ func TestExciseLoops(t *testing.T) {
for i, test := range loopTests {
gotSet := make(contourSet)
c := &contour{
backward: append(path(nil), test.c.backward...),
forward: append(path(nil), test.c.forward...),
backward: slices.Clone(test.c.backward),
forward: slices.Clone(test.c.forward),
}
gotSet[c] = struct{}{}
c.exciseLoops(gotSet, quick)
Expand Down
12 changes: 6 additions & 6 deletions plotter/field.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,8 +66,8 @@ type Field struct {
func NewField(f FieldXY) *Field {
max := math.Inf(-1)
c, r := f.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := f.Vector(i, j)
d := math.Hypot(v.X, v.Y)
if math.IsNaN(d) {
Expand All@@ -93,7 +93,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
trX, trY := plt.Transforms(&c)

cols, rows := f.FieldXY.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -111,7 +111,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
left = -(f.FieldXY.X(i) - f.FieldXY.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -200,8 +200,8 @@ func (f *Field) DataRange() (xmin, xmax, ymin, ymax float64) {
func (f *Field) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := f.FieldXY.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(f.FieldXY.X(i)),
Y: plt.Y.Norm(f.FieldXY.Y(j)),
Expand Down
16 changes: 8 additions & 8 deletions plotter/heat.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,8 +81,8 @@ func NewHeatMap(g GridXYZ, p palette.Palette) *HeatMap {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -120,8 +120,8 @@ func (h *HeatMap) plotRasterized(c draw.Canvas, plt *plot.Plot) {

pal := h.Palette.Colors()
ps := float64(len(pal)-1) / (h.Max - h.Min)
for i := 0; i < cols; i++ {
for j := 0; j < rows; j++ {
for i := range cols {
for j := range rows {
var col color.Color
switch v := h.GridXYZ.Z(i, j); {
case v < h.Min:
Expand DownExpand Up@@ -161,7 +161,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {

var pa vg.Path
cols, rows := h.GridXYZ.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -179,7 +179,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {
left = -(h.GridXYZ.X(i) - h.GridXYZ.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -258,8 +258,8 @@ func (h *HeatMap) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *HeatMap) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand Down
4 changes: 2 additions & 2 deletions plotter/histogram.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -186,7 +186,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
xmin, xmax := Range(XValues{xys})
if n <= 0 {
m := 0.0
for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
_, y := xys.XY(i)
m += math.Max(y, 1.0)
}
Expand All@@ -207,7 +207,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
bins[i].Max = xmin + float64(i+1)*w
}

for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
x, y := xys.XY(i)
bin := int((x - xmin) / w)
if x == xmax {
Expand Down
2 changes: 1 addition & 1 deletion plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,7 @@ func ExampleHistogram() {

n := 10000
vals := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
vals[i] = rnd.NormFloat64()
}

Expand Down
4 changes: 2 additions & 2 deletions plotter/image.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,13 +86,13 @@ func (img *Image) transformFor(p *plot.Plot) image.Image {
}
b := img.img.Bounds()
o := image.NewNRGBA64(b)
for c := 0; c < img.cols; c++ {
for c := range img.cols {
// Find the equivalent image column after applying axis transforms.
cTrans := int(p.X.Norm(img.x(c)) * float64(img.cols))
// Find the equivalent column of the previous image column after applying
// axis transforms.
cPrevTrans := int(p.X.Norm(img.x(maxInt(c-1, 0))) * float64(img.cols))
for r := 0; r < img.rows; r++ {
for r := range img.rows {
// Find the equivalent image row after applying axis transforms.
rTrans := int(p.Y.Norm(img.y(r)) * float64(img.rows))
// Find the equivalent row of the previous image row after applying
Expand Down
4 changes: 2 additions & 2 deletions plotter/plotter.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ type Valuer interface {
func Range(vs Valuer) (min, max float64) {
min = math.Inf(1)
max = math.Inf(-1)
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
v := vs.Value(i)
min = math.Min(min, v)
max = math.Max(max, v)
Expand DownExpand Up@@ -93,7 +93,7 @@ func CopyValues(vs Valuer) (Values, error) {
return nil, ErrNoData
}
cpy := make(Values, vs.Len())
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
cpy[i] = vs.Value(i)
if err := CheckFloats(cpy[i]); err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions plotter/polygon_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -121,9 +121,9 @@ func ExamplePolygon_hexagons() {
for i, xmin := range xstart {
ymin := ystart[i]
x := xmin
for ix := 0; ix < nx; ix++ {
for range nx {
y := ymin
for iy := 0; iy < ny; iy++ {
for range ny {
var poly *plotter.Polygon
poly, err = plotter.NewPolygon(hex(x, y, r))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ func ExampleQuartPlot() {
uniform := make(plotter.Values, n)
normal := make(plotter.Values, n)
expon := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i] = rnd.Float64()
normal[i] = rnd.NormFloat64()
expon[i] = rnd.ExpFloat64()
Expand Down
2 changes: 1 addition & 1 deletion plotter/rotation_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func Example_rotation() {
// Sin creates a sine curve.
sin := func(n int, xmax float64) plotter.XYs {
xy := make(plotter.XYs, n)
for i := 0; i < n; i++ {
for i := range n {
xy[i].X = xmax / float64(n) * float64(i)
xy[i].Y = math.Sin(xy[i].X) * 100
}
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions align.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,13 +25,13 @@ func Align(plots [][]*Plot, t draw.Tiles, dc draw.Canvas) [][]draw.Canvas {
}

// Create the initial tiles.
for j := 0; j < t.Rows; j++ {
for j := range t.Rows {
if len(plots[j]) != t.Cols {
panic(fmt.Errorf("plot: plots row %d columns (%d) != tiles columns (%d)", j, len(plots[j]), t.Rows))
}

o[j] = make([]draw.Canvas, len(plots[j]))
for i := 0; i < t.Cols; i++ {
for i := range t.Cols {
o[j][i] = t.At(dc, i, j)
}
}
Expand Down
8 changes: 4 additions & 4 deletions align_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,9 +18,9 @@ import (
func ExampleAlign() {
const rows, cols = 4, 3
plots := make([][]*plot.Plot, rows)
for j := 0; j < rows; j++ {
for j := range rows {
plots[j] = make([]*plot.Plot, cols)
for i := 0; i < cols; i++ {
for i := range cols {
if i == 0 && j == 2 {
// This shows what happens when there are nil plots.
continue
Expand DownExpand Up@@ -70,8 +70,8 @@ func ExampleAlign() {
}

canvases := plot.Align(plots, t, dc)
for j := 0; j < rows; j++ {
for i := 0; i < cols; i++ {
for j := range rows {
for i := range cols {
if plots[j][i] != nil {
plots[j][i].Draw(canvases[j][i])
}
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/brewer.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,7 +125,7 @@ func GetPalette(typ PaletteType, name string, colors int) (palette.Palette, erro
)
switch typ {
case TypeAny:
var pt interface{}
var pt any
pt, nameOk = all[name]
if !nameOk {
break
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/palettes.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -4752,7 +4752,7 @@ var (
"YlOrBr": YlOrBr,
"YlOrRd": YlOrRd,
}
all=map[string]interface{}{
all=map[string]any{
"BrBG": BrBG,
"PiYG": PiYG,
"PRGn": PRGn,
Expand Down
4 changes: 2 additions & 2 deletions palette/moreland/example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,8 +53,8 @@ func Example() {
YOffset: -50,
Data: mat.NewDense(100, 100, nil),
}
for i := 0; i < 100; i++ {
for j := 0; j < 100; j++ {
for i := range 100 {
for j := range 100 {
x := float64(i-50) / 10
y := float64(j-50) / 10
v := math.Sin(x*x+y*y) / (x*x + y*y)
Expand Down
2 changes: 1 addition & 1 deletion palette/moreland/luminance.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -178,7 +178,7 @@ func (l luminance) Palette(n int) palette.Palette {
delta := (l.max - l.min) / float64(n-1)
var v float64
c := make([]color.Color, n)
for i := 0; i < n; i++ {
for i := range n {
v = l.min + float64(delta*float64(i))
var err error
c[i], err = l.At(v)
Expand Down
2 changes: 1 addition & 1 deletion plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,7 +165,7 @@ func ExampleBarChart_positiveNegative() {
data1 := make(plotter.Values, n)
data2 := make(plotter.Values, n)
net := make(plotter.XYs, n) // net = data1 + data2
for i := 0; i < n; i++ {
for i := range n {
data1[i] = rnd.Float64()*2 - 1
data2[i] = rnd.Float64()*2 - 1
net[i].X = data1[i] + data2[i]
Expand Down
2 changes: 1 addition & 1 deletion plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func ExampleBoxPlot() {
uniform := make(plotter.ValueLabels, n)
normal := make(plotter.ValueLabels, n)
expon := make(plotter.ValueLabels, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i].Value = rnd.Float64()
uniform[i].Label = fmt.Sprintf("%4.4f", uniform[i].Value)
normal[i].Value = rnd.NormFloat64()
Expand Down
4 changes: 2 additions & 2 deletions plotter/colorbar.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,7 +62,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: 1, Y: colors},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand All@@ -75,7 +75,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: colors, Y: 1},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand Down
6 changes: 3 additions & 3 deletions plotter/conrec.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
)

c, r := g.Dims()
for i := 0; i < c-1; i++ {
for j := 0; j < r-1; j++ {
for i := range c - 1 {
for j := range r - 1 {
dmin := math.Min(
math.Min(g.Z(i, j), g.Z(i, j+1)),
math.Min(g.Z(i+1, j), g.Z(i+1, j+1)),
Expand All@@ -92,7 +92,7 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
continue
}

for k := 0; k < len(heights); k++ {
for k := range heights {
if heights[k] < dmin || dmax < heights[k] {
continue
}
Expand Down
15 changes: 8 additions & 7 deletions plotter/contour.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ package plotter
import (
"image/color"
"math"
"slices"
"sort"

"gonum.org/v1/plot"
Expand DownExpand Up@@ -64,8 +65,8 @@ func NewContour(g GridXYZ, levels []float64, p palette.Palette) *Contour {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -98,8 +99,8 @@ var defaultQuantiles = []float64{0.01, 0.05, 0.25, 0.5, 0.75, 0.95, 0.99}
func quantilesR7(g GridXYZ, p []float64) []float64 {
c, r := g.Dims()
data := make([]float64, 0, c*r)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
if v := g.Z(i, j); !math.IsNaN(v) {
data = append(data, v)
}
Expand DownExpand Up@@ -267,8 +268,8 @@ func (h *Contour) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *Contour) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand DownExpand Up@@ -651,7 +652,7 @@ func (c *contour) exciseQuick(conts contourSet) {
conts[&contour{
z: c.z,
backward: path{wp[i]},
forward: append(path(nil), wp[i+1:j+1]...),
forward: slices.Clone(wp[i+1 : j+1]),
}] = struct{}{}
wp = append(wp[:i], wp[j:]...)
j = i + 1
Expand Down
5 changes: 3 additions & 2 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import (
"fmt"
"math"
"reflect"
"slices"
"sort"
"testing"

Expand DownExpand Up@@ -457,8 +458,8 @@ func TestExciseLoops(t *testing.T) {
for i, test := range loopTests {
gotSet := make(contourSet)
c := &contour{
backward: append(path(nil), test.c.backward...),
forward: append(path(nil), test.c.forward...),
backward: slices.Clone(test.c.backward),
forward: slices.Clone(test.c.forward),
}
gotSet[c] = struct{}{}
c.exciseLoops(gotSet, quick)
Expand Down
12 changes: 6 additions & 6 deletions plotter/field.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,8 +66,8 @@ type Field struct {
func NewField(f FieldXY) *Field {
max := math.Inf(-1)
c, r := f.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := f.Vector(i, j)
d := math.Hypot(v.X, v.Y)
if math.IsNaN(d) {
Expand All@@ -93,7 +93,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
trX, trY := plt.Transforms(&c)

cols, rows := f.FieldXY.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -111,7 +111,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
left = -(f.FieldXY.X(i) - f.FieldXY.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -200,8 +200,8 @@ func (f *Field) DataRange() (xmin, xmax, ymin, ymax float64) {
func (f *Field) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := f.FieldXY.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(f.FieldXY.X(i)),
Y: plt.Y.Norm(f.FieldXY.Y(j)),
Expand Down
16 changes: 8 additions & 8 deletions plotter/heat.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,8 +81,8 @@ func NewHeatMap(g GridXYZ, p palette.Palette) *HeatMap {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -120,8 +120,8 @@ func (h *HeatMap) plotRasterized(c draw.Canvas, plt *plot.Plot) {

pal := h.Palette.Colors()
ps := float64(len(pal)-1) / (h.Max - h.Min)
for i := 0; i < cols; i++ {
for j := 0; j < rows; j++ {
for i := range cols {
for j := range rows {
var col color.Color
switch v := h.GridXYZ.Z(i, j); {
case v < h.Min:
Expand DownExpand Up@@ -161,7 +161,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {

var pa vg.Path
cols, rows := h.GridXYZ.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -179,7 +179,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {
left = -(h.GridXYZ.X(i) - h.GridXYZ.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -258,8 +258,8 @@ func (h *HeatMap) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *HeatMap) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand Down
4 changes: 2 additions & 2 deletions plotter/histogram.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -186,7 +186,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
xmin, xmax := Range(XValues{xys})
if n <= 0 {
m := 0.0
for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
_, y := xys.XY(i)
m += math.Max(y, 1.0)
}
Expand All@@ -207,7 +207,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
bins[i].Max = xmin + float64(i+1)*w
}

for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
x, y := xys.XY(i)
bin := int((x - xmin) / w)
if x == xmax {
Expand Down
2 changes: 1 addition & 1 deletion plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,7 @@ func ExampleHistogram() {

n := 10000
vals := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
vals[i] = rnd.NormFloat64()
}

Expand Down
4 changes: 2 additions & 2 deletions plotter/image.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,13 +86,13 @@ func (img *Image) transformFor(p *plot.Plot) image.Image {
}
b := img.img.Bounds()
o := image.NewNRGBA64(b)
for c := 0; c < img.cols; c++ {
for c := range img.cols {
// Find the equivalent image column after applying axis transforms.
cTrans := int(p.X.Norm(img.x(c)) * float64(img.cols))
// Find the equivalent column of the previous image column after applying
// axis transforms.
cPrevTrans := int(p.X.Norm(img.x(maxInt(c-1, 0))) * float64(img.cols))
for r := 0; r < img.rows; r++ {
for r := range img.rows {
// Find the equivalent image row after applying axis transforms.
rTrans := int(p.Y.Norm(img.y(r)) * float64(img.rows))
// Find the equivalent row of the previous image row after applying
Expand Down
4 changes: 2 additions & 2 deletions plotter/plotter.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ type Valuer interface {
func Range(vs Valuer) (min, max float64) {
min = math.Inf(1)
max = math.Inf(-1)
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
v := vs.Value(i)
min = math.Min(min, v)
max = math.Max(max, v)
Expand DownExpand Up@@ -93,7 +93,7 @@ func CopyValues(vs Valuer) (Values, error) {
return nil, ErrNoData
}
cpy := make(Values, vs.Len())
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
cpy[i] = vs.Value(i)
if err := CheckFloats(cpy[i]); err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions plotter/polygon_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -121,9 +121,9 @@ func ExamplePolygon_hexagons() {
for i, xmin := range xstart {
ymin := ystart[i]
x := xmin
for ix := 0; ix < nx; ix++ {
for range nx {
y := ymin
for iy := 0; iy < ny; iy++ {
for range ny {
var poly *plotter.Polygon
poly, err = plotter.NewPolygon(hex(x, y, r))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ func ExampleQuartPlot() {
uniform := make(plotter.Values, n)
normal := make(plotter.Values, n)
expon := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i] = rnd.Float64()
normal[i] = rnd.NormFloat64()
expon[i] = rnd.ExpFloat64()
Expand Down
2 changes: 1 addition & 1 deletion plotter/rotation_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func Example_rotation() {
// Sin creates a sine curve.
sin := func(n int, xmax float64) plotter.XYs {
xy := make(plotter.XYs, n)
for i := 0; i < n; i++ {
for i := range n {
xy[i].X = xmax / float64(n) * float64(i)
xy[i].Y = math.Sin(xy[i].X) * 100
}
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions align.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,13 +25,13 @@ func Align(plots [][]*Plot, t draw.Tiles, dc draw.Canvas) [][]draw.Canvas {
}

// Create the initial tiles.
for j := 0; j < t.Rows; j++ {
for j := range t.Rows {
if len(plots[j]) != t.Cols {
panic(fmt.Errorf("plot: plots row %d columns (%d) != tiles columns (%d)", j, len(plots[j]), t.Rows))
}

o[j] = make([]draw.Canvas, len(plots[j]))
for i := 0; i < t.Cols; i++ {
for i := range t.Cols {
o[j][i] = t.At(dc, i, j)
}
}
Expand Down
8 changes: 4 additions & 4 deletions align_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,9 +18,9 @@ import (
func ExampleAlign() {
const rows, cols = 4, 3
plots := make([][]*plot.Plot, rows)
for j := 0; j < rows; j++ {
for j := range rows {
plots[j] = make([]*plot.Plot, cols)
for i := 0; i < cols; i++ {
for i := range cols {
if i == 0 && j == 2 {
// This shows what happens when there are nil plots.
continue
Expand DownExpand Up@@ -70,8 +70,8 @@ func ExampleAlign() {
}

canvases := plot.Align(plots, t, dc)
for j := 0; j < rows; j++ {
for i := 0; i < cols; i++ {
for j := range rows {
for i := range cols {
if plots[j][i] != nil {
plots[j][i].Draw(canvases[j][i])
}
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/brewer.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,7 +125,7 @@ func GetPalette(typ PaletteType, name string, colors int) (palette.Palette, erro
)
switch typ {
case TypeAny:
var pt interface{}
var pt any
pt, nameOk = all[name]
if !nameOk {
break
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/palettes.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -4752,7 +4752,7 @@ var (
"YlOrBr": YlOrBr,
"YlOrRd": YlOrRd,
}
all=map[string]interface{}{
all=map[string]any{
"BrBG": BrBG,
"PiYG": PiYG,
"PRGn": PRGn,
Expand Down
4 changes: 2 additions & 2 deletions palette/moreland/example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,8 +53,8 @@ func Example() {
YOffset: -50,
Data: mat.NewDense(100, 100, nil),
}
for i := 0; i < 100; i++ {
for j := 0; j < 100; j++ {
for i := range 100 {
for j := range 100 {
x := float64(i-50) / 10
y := float64(j-50) / 10
v := math.Sin(x*x+y*y) / (x*x + y*y)
Expand Down
2 changes: 1 addition & 1 deletion palette/moreland/luminance.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -178,7 +178,7 @@ func (l luminance) Palette(n int) palette.Palette {
delta := (l.max - l.min) / float64(n-1)
var v float64
c := make([]color.Color, n)
for i := 0; i < n; i++ {
for i := range n {
v = l.min + float64(delta*float64(i))
var err error
c[i], err = l.At(v)
Expand Down
2 changes: 1 addition & 1 deletion plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,7 +165,7 @@ func ExampleBarChart_positiveNegative() {
data1 := make(plotter.Values, n)
data2 := make(plotter.Values, n)
net := make(plotter.XYs, n) // net = data1 + data2
for i := 0; i < n; i++ {
for i := range n {
data1[i] = rnd.Float64()*2 - 1
data2[i] = rnd.Float64()*2 - 1
net[i].X = data1[i] + data2[i]
Expand Down
2 changes: 1 addition & 1 deletion plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func ExampleBoxPlot() {
uniform := make(plotter.ValueLabels, n)
normal := make(plotter.ValueLabels, n)
expon := make(plotter.ValueLabels, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i].Value = rnd.Float64()
uniform[i].Label = fmt.Sprintf("%4.4f", uniform[i].Value)
normal[i].Value = rnd.NormFloat64()
Expand Down
4 changes: 2 additions & 2 deletions plotter/colorbar.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,7 +62,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: 1, Y: colors},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand All@@ -75,7 +75,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: colors, Y: 1},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand Down
6 changes: 3 additions & 3 deletions plotter/conrec.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
)

c, r := g.Dims()
for i := 0; i < c-1; i++ {
for j := 0; j < r-1; j++ {
for i := range c - 1 {
for j := range r - 1 {
dmin := math.Min(
math.Min(g.Z(i, j), g.Z(i, j+1)),
math.Min(g.Z(i+1, j), g.Z(i+1, j+1)),
Expand All@@ -92,7 +92,7 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
continue
}

for k := 0; k < len(heights); k++ {
for k := range heights {
if heights[k] < dmin || dmax < heights[k] {
continue
}
Expand Down
15 changes: 8 additions & 7 deletions plotter/contour.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ package plotter
import (
"image/color"
"math"
"slices"
"sort"

"gonum.org/v1/plot"
Expand DownExpand Up@@ -64,8 +65,8 @@ func NewContour(g GridXYZ, levels []float64, p palette.Palette) *Contour {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -98,8 +99,8 @@ var defaultQuantiles = []float64{0.01, 0.05, 0.25, 0.5, 0.75, 0.95, 0.99}
func quantilesR7(g GridXYZ, p []float64) []float64 {
c, r := g.Dims()
data := make([]float64, 0, c*r)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
if v := g.Z(i, j); !math.IsNaN(v) {
data = append(data, v)
}
Expand DownExpand Up@@ -267,8 +268,8 @@ func (h *Contour) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *Contour) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand DownExpand Up@@ -651,7 +652,7 @@ func (c *contour) exciseQuick(conts contourSet) {
conts[&contour{
z: c.z,
backward: path{wp[i]},
forward: append(path(nil), wp[i+1:j+1]...),
forward: slices.Clone(wp[i+1 : j+1]),
}] = struct{}{}
wp = append(wp[:i], wp[j:]...)
j = i + 1
Expand Down
5 changes: 3 additions & 2 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import (
"fmt"
"math"
"reflect"
"slices"
"sort"
"testing"

Expand DownExpand Up@@ -457,8 +458,8 @@ func TestExciseLoops(t *testing.T) {
for i, test := range loopTests {
gotSet := make(contourSet)
c := &contour{
backward: append(path(nil), test.c.backward...),
forward: append(path(nil), test.c.forward...),
backward: slices.Clone(test.c.backward),
forward: slices.Clone(test.c.forward),
}
gotSet[c] = struct{}{}
c.exciseLoops(gotSet, quick)
Expand Down
12 changes: 6 additions & 6 deletions plotter/field.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,8 +66,8 @@ type Field struct {
func NewField(f FieldXY) *Field {
max := math.Inf(-1)
c, r := f.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := f.Vector(i, j)
d := math.Hypot(v.X, v.Y)
if math.IsNaN(d) {
Expand All@@ -93,7 +93,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
trX, trY := plt.Transforms(&c)

cols, rows := f.FieldXY.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -111,7 +111,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
left = -(f.FieldXY.X(i) - f.FieldXY.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -200,8 +200,8 @@ func (f *Field) DataRange() (xmin, xmax, ymin, ymax float64) {
func (f *Field) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := f.FieldXY.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(f.FieldXY.X(i)),
Y: plt.Y.Norm(f.FieldXY.Y(j)),
Expand Down
16 changes: 8 additions & 8 deletions plotter/heat.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,8 +81,8 @@ func NewHeatMap(g GridXYZ, p palette.Palette) *HeatMap {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -120,8 +120,8 @@ func (h *HeatMap) plotRasterized(c draw.Canvas, plt *plot.Plot) {

pal := h.Palette.Colors()
ps := float64(len(pal)-1) / (h.Max - h.Min)
for i := 0; i < cols; i++ {
for j := 0; j < rows; j++ {
for i := range cols {
for j := range rows {
var col color.Color
switch v := h.GridXYZ.Z(i, j); {
case v < h.Min:
Expand DownExpand Up@@ -161,7 +161,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {

var pa vg.Path
cols, rows := h.GridXYZ.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -179,7 +179,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {
left = -(h.GridXYZ.X(i) - h.GridXYZ.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -258,8 +258,8 @@ func (h *HeatMap) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *HeatMap) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand Down
4 changes: 2 additions & 2 deletions plotter/histogram.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -186,7 +186,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
xmin, xmax := Range(XValues{xys})
if n <= 0 {
m := 0.0
for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
_, y := xys.XY(i)
m += math.Max(y, 1.0)
}
Expand All@@ -207,7 +207,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
bins[i].Max = xmin + float64(i+1)*w
}

for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
x, y := xys.XY(i)
bin := int((x - xmin) / w)
if x == xmax {
Expand Down
2 changes: 1 addition & 1 deletion plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,7 @@ func ExampleHistogram() {

n := 10000
vals := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
vals[i] = rnd.NormFloat64()
}

Expand Down
4 changes: 2 additions & 2 deletions plotter/image.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,13 +86,13 @@ func (img *Image) transformFor(p *plot.Plot) image.Image {
}
b := img.img.Bounds()
o := image.NewNRGBA64(b)
for c := 0; c < img.cols; c++ {
for c := range img.cols {
// Find the equivalent image column after applying axis transforms.
cTrans := int(p.X.Norm(img.x(c)) * float64(img.cols))
// Find the equivalent column of the previous image column after applying
// axis transforms.
cPrevTrans := int(p.X.Norm(img.x(maxInt(c-1, 0))) * float64(img.cols))
for r := 0; r < img.rows; r++ {
for r := range img.rows {
// Find the equivalent image row after applying axis transforms.
rTrans := int(p.Y.Norm(img.y(r)) * float64(img.rows))
// Find the equivalent row of the previous image row after applying
Expand Down
4 changes: 2 additions & 2 deletions plotter/plotter.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ type Valuer interface {
func Range(vs Valuer) (min, max float64) {
min = math.Inf(1)
max = math.Inf(-1)
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
v := vs.Value(i)
min = math.Min(min, v)
max = math.Max(max, v)
Expand DownExpand Up@@ -93,7 +93,7 @@ func CopyValues(vs Valuer) (Values, error) {
return nil, ErrNoData
}
cpy := make(Values, vs.Len())
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
cpy[i] = vs.Value(i)
if err := CheckFloats(cpy[i]); err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions plotter/polygon_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -121,9 +121,9 @@ func ExamplePolygon_hexagons() {
for i, xmin := range xstart {
ymin := ystart[i]
x := xmin
for ix := 0; ix < nx; ix++ {
for range nx {
y := ymin
for iy := 0; iy < ny; iy++ {
for range ny {
var poly *plotter.Polygon
poly, err = plotter.NewPolygon(hex(x, y, r))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ func ExampleQuartPlot() {
uniform := make(plotter.Values, n)
normal := make(plotter.Values, n)
expon := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i] = rnd.Float64()
normal[i] = rnd.NormFloat64()
expon[i] = rnd.ExpFloat64()
Expand Down
2 changes: 1 addition & 1 deletion plotter/rotation_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func Example_rotation() {
// Sin creates a sine curve.
sin := func(n int, xmax float64) plotter.XYs {
xy := make(plotter.XYs, n)
for i := 0; i < n; i++ {
for i := range n {
xy[i].X = xmax / float64(n) * float64(i)
xy[i].Y = math.Sin(xy[i].X) * 100
}
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions align.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,13 +25,13 @@ func Align(plots [][]*Plot, t draw.Tiles, dc draw.Canvas) [][]draw.Canvas {
}

// Create the initial tiles.
for j := 0; j < t.Rows; j++ {
for j := range t.Rows {
if len(plots[j]) != t.Cols {
panic(fmt.Errorf("plot: plots row %d columns (%d) != tiles columns (%d)", j, len(plots[j]), t.Rows))
}

o[j] = make([]draw.Canvas, len(plots[j]))
for i := 0; i < t.Cols; i++ {
for i := range t.Cols {
o[j][i] = t.At(dc, i, j)
}
}
Expand Down
8 changes: 4 additions & 4 deletions align_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,9 +18,9 @@ import (
func ExampleAlign() {
const rows, cols = 4, 3
plots := make([][]*plot.Plot, rows)
for j := 0; j < rows; j++ {
for j := range rows {
plots[j] = make([]*plot.Plot, cols)
for i := 0; i < cols; i++ {
for i := range cols {
if i == 0 && j == 2 {
// This shows what happens when there are nil plots.
continue
Expand DownExpand Up@@ -70,8 +70,8 @@ func ExampleAlign() {
}

canvases := plot.Align(plots, t, dc)
for j := 0; j < rows; j++ {
for i := 0; i < cols; i++ {
for j := range rows {
for i := range cols {
if plots[j][i] != nil {
plots[j][i].Draw(canvases[j][i])
}
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/brewer.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,7 +125,7 @@ func GetPalette(typ PaletteType, name string, colors int) (palette.Palette, erro
)
switch typ {
case TypeAny:
var pt interface{}
var pt any
pt, nameOk = all[name]
if !nameOk {
break
Expand Down
2 changes: 1 addition & 1 deletion palette/brewer/palettes.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -4752,7 +4752,7 @@ var (
"YlOrBr": YlOrBr,
"YlOrRd": YlOrRd,
}
all=map[string]interface{}{
all=map[string]any{
"BrBG": BrBG,
"PiYG": PiYG,
"PRGn": PRGn,
Expand Down
4 changes: 2 additions & 2 deletions palette/moreland/example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,8 +53,8 @@ func Example() {
YOffset: -50,
Data: mat.NewDense(100, 100, nil),
}
for i := 0; i < 100; i++ {
for j := 0; j < 100; j++ {
for i := range 100 {
for j := range 100 {
x := float64(i-50) / 10
y := float64(j-50) / 10
v := math.Sin(x*x+y*y) / (x*x + y*y)
Expand Down
2 changes: 1 addition & 1 deletion palette/moreland/luminance.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -178,7 +178,7 @@ func (l luminance) Palette(n int) palette.Palette {
delta := (l.max - l.min) / float64(n-1)
var v float64
c := make([]color.Color, n)
for i := 0; i < n; i++ {
for i := range n {
v = l.min + float64(delta*float64(i))
var err error
c[i], err = l.At(v)
Expand Down
2 changes: 1 addition & 1 deletion plotter/barchart_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -165,7 +165,7 @@ func ExampleBarChart_positiveNegative() {
data1 := make(plotter.Values, n)
data2 := make(plotter.Values, n)
net := make(plotter.XYs, n) // net = data1 + data2
for i := 0; i < n; i++ {
for i := range n {
data1[i] = rnd.Float64()*2 - 1
data2[i] = rnd.Float64()*2 - 1
net[i].X = data1[i] + data2[i]
Expand Down
2 changes: 1 addition & 1 deletion plotter/boxplot_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func ExampleBoxPlot() {
uniform := make(plotter.ValueLabels, n)
normal := make(plotter.ValueLabels, n)
expon := make(plotter.ValueLabels, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i].Value = rnd.Float64()
uniform[i].Label = fmt.Sprintf("%4.4f", uniform[i].Value)
normal[i].Value = rnd.NormFloat64()
Expand Down
4 changes: 2 additions & 2 deletions plotter/colorbar.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -62,7 +62,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: 1, Y: colors},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand All@@ -75,7 +75,7 @@ func (l *ColorBar) Plot(c draw.Canvas, p *plot.Plot) {
Min: image.Point{X: 0, Y: 0},
Max: image.Point{X: colors, Y: 1},
})
for i := 0; i < colors; i++ {
for i := range colors {
color, err := l.ColorMap.At(l.ColorMap.Min() + delta*float64(i))
if err != nil {
panic(err)
Expand Down
6 changes: 3 additions & 3 deletions plotter/conrec.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,8 +76,8 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
)

c, r := g.Dims()
for i := 0; i < c-1; i++ {
for j := 0; j < r-1; j++ {
for i := range c - 1 {
for j := range r - 1 {
dmin := math.Min(
math.Min(g.Z(i, j), g.Z(i, j+1)),
math.Min(g.Z(i+1, j), g.Z(i+1, j+1)),
Expand All@@ -92,7 +92,7 @@ func conrec(g GridXYZ, heights []float64, fn conrecLine) {
continue
}

for k := 0; k < len(heights); k++ {
for k := range heights {
if heights[k] < dmin || dmax < heights[k] {
continue
}
Expand Down
15 changes: 8 additions & 7 deletions plotter/contour.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ package plotter
import (
"image/color"
"math"
"slices"
"sort"

"gonum.org/v1/plot"
Expand DownExpand Up@@ -64,8 +65,8 @@ func NewContour(g GridXYZ, levels []float64, p palette.Palette) *Contour {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -98,8 +99,8 @@ var defaultQuantiles = []float64{0.01, 0.05, 0.25, 0.5, 0.75, 0.95, 0.99}
func quantilesR7(g GridXYZ, p []float64) []float64 {
c, r := g.Dims()
data := make([]float64, 0, c*r)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
if v := g.Z(i, j); !math.IsNaN(v) {
data = append(data, v)
}
Expand DownExpand Up@@ -267,8 +268,8 @@ func (h *Contour) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *Contour) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand DownExpand Up@@ -651,7 +652,7 @@ func (c *contour) exciseQuick(conts contourSet) {
conts[&contour{
z: c.z,
backward: path{wp[i]},
forward: append(path(nil), wp[i+1:j+1]...),
forward: slices.Clone(wp[i+1 : j+1]),
}] = struct{}{}
wp = append(wp[:i], wp[j:]...)
j = i + 1
Expand Down
5 changes: 3 additions & 2 deletions plotter/contour_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import (
"fmt"
"math"
"reflect"
"slices"
"sort"
"testing"

Expand DownExpand Up@@ -457,8 +458,8 @@ func TestExciseLoops(t *testing.T) {
for i, test := range loopTests {
gotSet := make(contourSet)
c := &contour{
backward: append(path(nil), test.c.backward...),
forward: append(path(nil), test.c.forward...),
backward: slices.Clone(test.c.backward),
forward: slices.Clone(test.c.forward),
}
gotSet[c] = struct{}{}
c.exciseLoops(gotSet, quick)
Expand Down
12 changes: 6 additions & 6 deletions plotter/field.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -66,8 +66,8 @@ type Field struct {
func NewField(f FieldXY) *Field {
max := math.Inf(-1)
c, r := f.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := f.Vector(i, j)
d := math.Hypot(v.X, v.Y)
if math.IsNaN(d) {
Expand All@@ -93,7 +93,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
trX, trY := plt.Transforms(&c)

cols, rows := f.FieldXY.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -111,7 +111,7 @@ func (f *Field) Plot(c draw.Canvas, plt *plot.Plot) {
left = -(f.FieldXY.X(i) - f.FieldXY.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -200,8 +200,8 @@ func (f *Field) DataRange() (xmin, xmax, ymin, ymax float64) {
func (f *Field) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := f.FieldXY.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(f.FieldXY.X(i)),
Y: plt.Y.Norm(f.FieldXY.Y(j)),
Expand Down
16 changes: 8 additions & 8 deletions plotter/heat.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,8 +81,8 @@ func NewHeatMap(g GridXYZ, p palette.Palette) *HeatMap {
default:
min, max = math.Inf(1), math.Inf(-1)
c, r := g.Dims()
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
v := g.Z(i, j)
if math.IsNaN(v) {
continue
Expand DownExpand Up@@ -120,8 +120,8 @@ func (h *HeatMap) plotRasterized(c draw.Canvas, plt *plot.Plot) {

pal := h.Palette.Colors()
ps := float64(len(pal)-1) / (h.Max - h.Min)
for i := 0; i < cols; i++ {
for j := 0; j < rows; j++ {
for i := range cols {
for j := range rows {
var col color.Color
switch v := h.GridXYZ.Z(i, j); {
case v < h.Min:
Expand DownExpand Up@@ -161,7 +161,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {

var pa vg.Path
cols, rows := h.GridXYZ.Dims()
for i := 0; i < cols; i++ {
for i := range cols {
var right, left float64
switch i {
case 0:
Expand All@@ -179,7 +179,7 @@ func (h *HeatMap) plotVectorized(c draw.Canvas, plt *plot.Plot) {
left = -(h.GridXYZ.X(i) - h.GridXYZ.X(i-1)) / 2
}

for j := 0; j < rows; j++ {
for j := range rows {
var up, down float64
switch j {
case 0:
Expand DownExpand Up@@ -258,8 +258,8 @@ func (h *HeatMap) DataRange() (xmin, xmax, ymin, ymax float64) {
func (h *HeatMap) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox {
c, r := h.GridXYZ.Dims()
b := make([]plot.GlyphBox, 0, r*c)
for i := 0; i < c; i++ {
for j := 0; j < r; j++ {
for i := range c {
for j := range r {
b = append(b, plot.GlyphBox{
X: plt.X.Norm(h.GridXYZ.X(i)),
Y: plt.Y.Norm(h.GridXYZ.Y(j)),
Expand Down
4 changes: 2 additions & 2 deletions plotter/histogram.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -186,7 +186,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
xmin, xmax := Range(XValues{xys})
if n <= 0 {
m := 0.0
for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
_, y := xys.XY(i)
m += math.Max(y, 1.0)
}
Expand All@@ -207,7 +207,7 @@ func binPoints(xys XYer, n int) (bins []HistogramBin, width float64) {
bins[i].Max = xmin + float64(i+1)*w
}

for i := 0; i < xys.Len(); i++ {
for i := range xys.Len() {
x, y := xys.XY(i)
bin := int((x - xmin) / w)
if x == xmax {
Expand Down
2 changes: 1 addition & 1 deletion plotter/histogram_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,7 +31,7 @@ func ExampleHistogram() {

n := 10000
vals := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
vals[i] = rnd.NormFloat64()
}

Expand Down
4 changes: 2 additions & 2 deletions plotter/image.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,13 +86,13 @@ func (img *Image) transformFor(p *plot.Plot) image.Image {
}
b := img.img.Bounds()
o := image.NewNRGBA64(b)
for c := 0; c < img.cols; c++ {
for c := range img.cols {
// Find the equivalent image column after applying axis transforms.
cTrans := int(p.X.Norm(img.x(c)) * float64(img.cols))
// Find the equivalent column of the previous image column after applying
// axis transforms.
cPrevTrans := int(p.X.Norm(img.x(maxInt(c-1, 0))) * float64(img.cols))
for r := 0; r < img.rows; r++ {
for r := range img.rows {
// Find the equivalent image row after applying axis transforms.
rTrans := int(p.Y.Norm(img.y(r)) * float64(img.rows))
// Find the equivalent row of the previous image row after applying
Expand Down
4 changes: 2 additions & 2 deletions plotter/plotter.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ type Valuer interface {
func Range(vs Valuer) (min, max float64) {
min = math.Inf(1)
max = math.Inf(-1)
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
v := vs.Value(i)
min = math.Min(min, v)
max = math.Max(max, v)
Expand DownExpand Up@@ -93,7 +93,7 @@ func CopyValues(vs Valuer) (Values, error) {
return nil, ErrNoData
}
cpy := make(Values, vs.Len())
for i := 0; i < vs.Len(); i++ {
for i := range vs.Len() {
cpy[i] = vs.Value(i)
if err := CheckFloats(cpy[i]); err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions plotter/polygon_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -121,9 +121,9 @@ func ExamplePolygon_hexagons() {
for i, xmin := range xstart {
ymin := ystart[i]
x := xmin
for ix := 0; ix < nx; ix++ {
for range nx {
y := ymin
for iy := 0; iy < ny; iy++ {
for range ny {
var poly *plotter.Polygon
poly, err = plotter.NewPolygon(hex(x, y, r))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion plotter/quartile_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ func ExampleQuartPlot() {
uniform := make(plotter.Values, n)
normal := make(plotter.Values, n)
expon := make(plotter.Values, n)
for i := 0; i < n; i++ {
for i := range n {
uniform[i] = rnd.Float64()
normal[i] = rnd.NormFloat64()
expon[i] = rnd.ExpFloat64()
Expand Down
2 changes: 1 addition & 1 deletion plotter/rotation_example_test.go
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@ func Example_rotation() {
// Sin creates a sine curve.
sin := func(n int, xmax float64) plotter.XYs {
xy := make(plotter.XYs, n)
for i := 0; i < n; i++ {
for i := range n {
xy[i].X = xmax / float64(n) * float64(i)
xy[i].Y = math.Sin(xy[i].X) * 100
}
Expand Down
Loading