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
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
codeberg.org/go-pdf/fpdf v0.10.0
git.sr.ht/~sbinet/gg v0.6.0
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
golang.org/x/image v0.25.0
gonum.org/v1/gonum v0.16.0
rsc.io/pdf v0.1.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY=
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8=
golang.org/x/image v0.25.0 h1:Y6uW6rH1y5y/LK1J8BPWZtr6yZ7hrsy6hFrXjgsc2fQ=
golang.org/x/image v0.25.0/go.mod h1:tCAmOEGthTtkalusGp1g3xa2gke8J6c2N565dTyl9Rs=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
Expand Down
5 changes: 2 additions & 3 deletions gob/gob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import (
"bytes"
"encoding/gob"
"image/color"
"math/rand/v2"
"os"
"testing"

"golang.org/x/exp/rand"

"gonum.org/v1/plot"
_ "gonum.org/v1/plot/gob"
"gonum.org/v1/plot/plotter"
Expand All @@ -25,7 +24,7 @@ func init() {
}

func TestPersistency(t *testing.T) {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Get some random points
n := 15
Expand Down
7 changes: 3 additions & 4 deletions palette/moreland/luminance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ package moreland
import (
"fmt"
"image/color"
"math/rand/v2"
"testing"

"golang.org/x/exp/rand"

"gonum.org/v1/gonum/floats/scalar"
)

Expand Down Expand Up @@ -151,10 +150,10 @@ func BenchmarkLuminance_At(b *testing.B) {
b.Fatal(err)
}
p.SetMax(1)
rand.Seed(1)
rng := rand.New(rand.NewPCG(1, 1))
b.Run(fmt.Sprintf("%d controls", n), func(b *testing.B) {
for i := 0; i < b.N; i++ {
if _, err := p.At(rand.Float64()); err != nil {
if _, err := p.At(rng.Float64()); err != nil {
b.Fatal(err)
}
}
Expand Down
8 changes: 3 additions & 5 deletions palette/moreland/smooth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ package moreland
import (
"image/color"
"math"
"math/rand/v2"
"strings"
"testing"

"golang.org/x/exp/rand"

"gonum.org/v1/plot/palette"
)

Expand Down Expand Up @@ -177,7 +176,6 @@ func testRGB(t *testing.T, i int, label string, c1 color.Color, c2 [3]float64) {
}

func TestSmoothDiverging_At(t *testing.T) {

start := msh{M: 80, S: 1.08, H: -1.1}
end := msh{M: 80, S: 1.08, H: 0.5}
p := newSmoothDiverging(start, end, 88)
Expand All @@ -199,9 +197,9 @@ func TestSmoothDiverging_At(t *testing.T) {
func BenchmarkSmoothDiverging_At(b *testing.B) {
p := SmoothBlueRed()
p.SetMax(1.0000000001)
rand.Seed(1)
rng := rand.New(rand.NewPCG(1, 1))
for i := 0; i < b.N; i++ {
if _, err := p.At(rand.Float64()); err != nil {
if _, err := p.At(rng.Float64()); err != nil {
b.Fatal(err)
}
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/barchart_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ package plotter_test
import (
"image/color"
"log"
"math/rand/v2"
"runtime"

"golang.org/x/exp/rand"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
Expand Down Expand Up @@ -158,7 +157,7 @@ func ExampleBarChart() {

// This example shows a bar chart with both positive and negative values.
func ExampleBarChart_positiveNegative() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create random data points between -1 and 1.
const n = 6
Expand Down
5 changes: 2 additions & 3 deletions plotter/boxplot_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ import (
"fmt"
"image/color"
"log"

"golang.org/x/exp/rand"
"math/rand/v2"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleBoxPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the sample data.
const n = 100
Expand Down
5 changes: 2 additions & 3 deletions plotter/bubbles_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
"image/color"
"log"
"math"

"golang.org/x/exp/rand"
"math/rand/v2"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
Expand All @@ -21,7 +20,7 @@ import (
// Each point is plotted with a different radius size depending on
// external criteria.
func ExampleScatter_bubbles() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// randomTriples returns some random but correlated x, y, z triples
randomTriples := func(n int) plotter.XYZs {
Expand Down
5 changes: 2 additions & 3 deletions plotter/contour_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ package plotter_test
import (
"log"
"math"
"math/rand/v2"
"runtime"
"testing"

"golang.org/x/exp/rand"

"gonum.org/v1/gonum/mat"
"gonum.org/v1/plot"
"gonum.org/v1/plot/cmpimg"
Expand All @@ -21,7 +20,7 @@ import (
)

func ExampleContour() {
rnd := rand.New(rand.NewSource(1234))
rnd := rand.New(rand.NewPCG(1234, 1234))

const stddev = 2
data := make([]float64, 6400)
Expand Down
7 changes: 3 additions & 4 deletions plotter/contour_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import (
"flag"
"fmt"
"math"
"math/rand/v2"
"reflect"
"slices"
"sort"
"testing"

"golang.org/x/exp/rand"

"gonum.org/v1/gonum/mat"
"gonum.org/v1/plot"
"gonum.org/v1/plot/palette"
Expand Down Expand Up @@ -74,7 +73,7 @@ func TestHeatMapWithContour(t *testing.T) {
}

func TestComplexContours(t *testing.T) {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

if !*visualDebug {
return
Expand Down Expand Up @@ -121,7 +120,7 @@ func BenchmarkComplexContour32(b *testing.B) { complexContourBench(32, b) }
var cp map[float64][]vg.Path

func complexContourBench(noise float64, b *testing.B) {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

data := make([]float64, 6400)
for i := range data {
Expand Down
5 changes: 2 additions & 3 deletions plotter/errbars_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ package plotter_test

import (
"log"

"golang.org/x/exp/rand"
"math/rand/v2"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
Expand All @@ -16,7 +15,7 @@ import (

// ExampleErrors draws points and error bars.
func ExampleErrors() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

randomError := func(n int) plotter.Errors {
err := make(plotter.Errors, n)
Expand Down
8 changes: 4 additions & 4 deletions plotter/filledLine_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ package plotter_test
import (
"image/color"
"log"

"golang.org/x/exp/rand"
"math/rand/v2"
"runtime"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
)

func ExampleLine_filledLine() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// randomPoints returns some random x, y points
// with some interesting kind of trend.
Expand Down Expand Up @@ -46,7 +46,7 @@ func ExampleLine_filledLine() {

p.Add(filled)

err = p.Save(200, 200, "testdata/filledLine.png")
err = p.Save(200, 200, "testdata/filledLine_"+runtime.GOARCH+".png")
if err != nil {
log.Panic(err)
}
Expand Down
12 changes: 6 additions & 6 deletions plotter/filledLine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ package plotter_test
import (
"image/color"
"log"
"math/rand/v2"
"runtime"
"testing"

"golang.org/x/exp/rand"

"gonum.org/v1/plot"
"gonum.org/v1/plot/cmpimg"
"gonum.org/v1/plot/plotter"
)

// See https://github.com/gonum/plot/issues/488
func clippedFilledLine() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// randomPoints returns some random x, y points
// with some interesting kind of trend.
Expand Down Expand Up @@ -49,8 +49,8 @@ func clippedFilledLine() {

p.Add(filled)
// testing clipping
p.X.Min, p.X.Max = 1, 3
p.Y.Max = -1
p.X.Min, p.X.Max = 1, 3.5
p.Y.Max = 4

err = p.Save(200, 200, "testdata/clippedFilledLine.png")
if err != nil {
Expand All @@ -59,6 +59,6 @@ func clippedFilledLine() {
}

func TestFilledLine(t *testing.T) {
cmpimg.CheckPlot(ExampleLine_filledLine, t, "filledLine.png")
cmpimg.CheckPlot(ExampleLine_filledLine, t, "filledLine_"+runtime.GOARCH+".png")
cmpimg.CheckPlot(clippedFilledLine, t, "clippedFilledLine.png")
}
5 changes: 2 additions & 3 deletions plotter/histogram_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
"image/color"
"log"
"math"

"golang.org/x/exp/rand"
"math/rand/v2"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
Expand All @@ -18,7 +17,7 @@ import (

// An example of making a histogram.
func ExampleHistogram() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// stdNorm returns the probability of drawing a
// value from a standard normal distribution.
Expand Down
5 changes: 2 additions & 3 deletions plotter/quartile_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ package plotter_test

import (
"log"

"golang.org/x/exp/rand"
"math/rand/v2"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
"gonum.org/v1/plot/vg"
)

func ExampleQuartPlot() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// Create the example data.
n := 100
Expand Down
8 changes: 4 additions & 4 deletions plotter/scatterColor_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import (
"fmt"
"log"
"math"
"math/rand/v2"
"os"

"golang.org/x/exp/rand"

"gonum.org/v1/plot"
"gonum.org/v1/plot/palette/moreland"
"gonum.org/v1/plot/plotter"
Expand All @@ -24,7 +23,7 @@ import (
// Each point is plotted with a different color depending on
// external criteria.
func ExampleScatter_color() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// randomTriples returns some random but correlated x, y, z triples
randomTriples := func(n int) plotter.XYZs {
Expand Down Expand Up @@ -76,7 +75,8 @@ func ExampleScatter_color() {
d := (z - minZ) / (maxZ - minZ)
rng := maxZ - minZ
k := d*rng + minZ
c, err := colors.At(k)
// Clamp k to avoid potential overflow due to floating point error.
c, err := colors.At(min(k, colors.Max()))
if err != nil {
log.Panic(err)
}
Expand Down
5 changes: 2 additions & 3 deletions plotter/scatter_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ package plotter_test
import (
"image/color"
"log"

"golang.org/x/exp/rand"
"math/rand/v2"

"gonum.org/v1/plot"
"gonum.org/v1/plot/plotter"
Expand All @@ -19,7 +18,7 @@ import (
// ExampleScatter draws some scatter points, a line,
// and a line with points.
func ExampleScatter() {
rnd := rand.New(rand.NewSource(1))
rnd := rand.New(rand.NewPCG(1, 1))

// randomPoints returns some random x, y points
// with some interesting kind of trend.
Expand Down
Loading
Loading