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
15 changes: 15 additions & 0 deletions docs/content/plot.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ plt := lab.NewPlot(b)
plots.NewLine(plt, data)
```

## Out-of-Range data

You can set fixed Min / Max ranges to plot, for either axis. By default, the out-of-range data will show up as a break in the plot line, with red X's marking the out-of-range points. This behavior can be adjusted by changing the `OutOfRange` property in the [[doc:plot.PlotStyle]].

```Goal
data := #rand(10)#
plot.SetStyler(data, func(s *plot.Style) {
s.Range.SetMin(0.2) // sets a FixMin flag to indicate a fixed min has been set.
s.Range.SetMax(0.8)
s.Plot.OutOfRange = plot.BreakMark // default
})
plt := lab.NewPlot(b)
plots.NewLine(plt, data)
```

## Plot Types

The following are the builtin standard plot types, in the `plots` package:
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go 1.25.6
// https://github.com/googleapis/go-genproto/issues/1015

require (
cogentcore.org/core v0.3.25
cogentcore.org/core v0.3.28
github.com/cogentcore/readline v0.1.3
github.com/cogentcore/yaegi v0.0.0-20260116172027-700fbf8949f3
github.com/mitchellh/go-homedir v1.1.0
Expand Down Expand Up @@ -38,10 +38,10 @@ require (
github.com/ericchiang/css v1.4.0 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/go-fonts/latin-modern v0.3.3 // indirect
github.com/go-gl/glfw/v3.4/glfw v0.1.0-pre.1 // indirect
github.com/go-gl/glfw/v3.4/glfw v0.1.0-pre.1.0.20260406072232-3ac4aa2bb164 // indirect
github.com/go-text/typesetting v0.3.5-0.20260418130854-c41d02a44bec // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gomarkdown/markdown v0.0.0-20250810172220-2e2c11897d1a // indirect
github.com/gomarkdown/markdown v0.0.0-20260417124207-7d523f7318df // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/h2non/filetype v1.1.3 // indirect
github.com/hack-pad/go-indexeddb v0.3.2 // indirect
Expand All @@ -66,8 +66,8 @@ require (
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.42.0 // indirect
golang.org/x/text v0.36.0 // indirect
google.golang.org/genproto v0.0.0-20260420184626-e10c466a9529 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 // indirect
google.golang.org/genproto v0.0.0-20260511170946-3700d4141b60 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/knuth v0.5.4 // indirect
modernc.org/token v1.1.0 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
codeberg.org/go-pdf/fpdf v0.11.0 h1:n3I8WISQ1cr0S2rvx9DOlE/GypbcimMWqLpel3slHmY=
codeberg.org/go-pdf/fpdf v0.11.0/go.mod h1:Y0DGRAdZ0OmnZPvjbMp/1bYxmIPxm0ws4tfoPOc4LjU=
cogentcore.org/core v0.3.25 h1:nrECnVQIl/JvyGFae5c/KystUAlLwSmIsjW1MkpkpiU=
cogentcore.org/core v0.3.25/go.mod h1:+5R2kihBnWrFmRlYd8yJ8JmRuLsGgCXXgvcgLk/YDEI=
cogentcore.org/core v0.3.28 h1:4sE28se7PLtDrYESg9W1hirOYY9Pddkle0cLxCLPZyw=
cogentcore.org/core v0.3.28/go.mod h1:IuX9mO4iQAMACI3yJbRfPmCN+PM+Z+mbJrFXa9fc7sg=
git.sr.ht/~sbinet/cmpimg v0.1.0 h1:E0zPRk2muWuCqSKSVZIWsgtU9pjsw3eKHi8VmQeScxo=
git.sr.ht/~sbinet/cmpimg v0.1.0/go.mod h1:FU12psLbF4TfNXkKH2ZZQ29crIqoiqTZmeQ7dkp/pxE=
github.com/Bios-Marcel/wastebasket/v2 v2.0.3 h1:TkoDPcSqluhLGE+EssHu7UGmLgUEkWg7kNyHyyJ3Q9g=
Expand Down Expand Up @@ -47,8 +47,8 @@ github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/go-fonts/latin-modern v0.3.3 h1:g2xNgI8yzdNzIVm+qvbMryB6yGPe0pSMss8QT3QwlJ0=
github.com/go-fonts/latin-modern v0.3.3/go.mod h1:tHaiWDGze4EPB0Go4cLT5M3QzRY3peya09Z/8KSCrpY=
github.com/go-gl/glfw/v3.4/glfw v0.1.0-pre.1 h1:nIVzcwqIaO1mK8LFr0fGkKpgQD4wJDDHRyv4t5k40Ps=
github.com/go-gl/glfw/v3.4/glfw v0.1.0-pre.1/go.mod h1:T5Dn0JwIJOX1euPZ/iT4tq6nFYtmukjcYa7937HuYK8=
github.com/go-gl/glfw/v3.4/glfw v0.1.0-pre.1.0.20260406072232-3ac4aa2bb164 h1:c87Nyz3ox3QbCl0yozQPeVPW4mmgFOSKY4yyc1TrS0w=
github.com/go-gl/glfw/v3.4/glfw v0.1.0-pre.1.0.20260406072232-3ac4aa2bb164/go.mod h1:T5Dn0JwIJOX1euPZ/iT4tq6nFYtmukjcYa7937HuYK8=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
Expand All @@ -61,8 +61,8 @@ github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/gomarkdown/markdown v0.0.0-20250810172220-2e2c11897d1a h1:l7A0loSszR5zHd/qK53ZIHMO8b3bBSmENnQ6eKnUT0A=
github.com/gomarkdown/markdown v0.0.0-20250810172220-2e2c11897d1a/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
github.com/gomarkdown/markdown v0.0.0-20260417124207-7d523f7318df h1:Mwihr/o+v4L5h56rwHLOE20+hh7Okhwno5BHz3zDuao=
github.com/gomarkdown/markdown v0.0.0-20260417124207-7d523f7318df/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
Expand Down Expand Up @@ -167,10 +167,10 @@ golang.org/x/tools v0.43.0/go.mod h1:uHkMso649BX2cZK6+RpuIPXS3ho2hZo4FVwfoy1vIk0
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
google.golang.org/genproto v0.0.0-20260420184626-e10c466a9529 h1:QoMBg0moLIlB/eucPzc+ID5SgPZWuirtjAn3l8nW2Dg=
google.golang.org/genproto v0.0.0-20260420184626-e10c466a9529/go.mod h1:EjLmDZ8liSLBrCTK5vP+bGIxRQHE3ovGvOI0CzGk1PI=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 h1:RmoJA1ujG+/lRGNfUnOMfhCy5EipVMyvUE+KNbPbTlw=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/genproto v0.0.0-20260511170946-3700d4141b60 h1:rhBdfmsOlOZIvz3Y5/BdUzPg2CkO8L7QQPKj96B8554=
google.golang.org/genproto v0.0.0-20260511170946-3700d4141b60/go.mod h1:8xo2Pj1b20ZOCpzlU3B9qieMwVIAXx1QVZWLMlPL6sM=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348 h1:pfIbyB44sWzHiCpRqIen67ZQnVXSfIxWrqUMk1qwODE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20260504160031-60b97b32f348/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8=
google.golang.org/grpc v1.80.0 h1:Xr6m2WmWZLETvUNvIUmeD5OAagMw3FiKmMlTdViWsHM=
google.golang.org/grpc v1.80.0/go.mod h1:ho/dLnxwi3EDJA4Zghp7k2Ec1+c2jqup0bFkw07bwF4=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
Expand Down
6 changes: 6 additions & 0 deletions gosl/gotosl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ type Config struct {
// and must fit in a uint32 number.
// The default is 32 byte aligned down version of 2147483647 max for nvidia
MaxBufferSize uint32 `default:"2147483616"`

// MaxStorageBuffersPerShaderStage is used to flag shaders that use more
// than this maximum number, which is the default max for web-based apps
// based on all the various backends. Specific backends may have more
// but using more will affect portability.
MaxStorageBuffersPerShaderStage int `default:"16"`
}

//cli:cmd -root
Expand Down
6 changes: 3 additions & 3 deletions gosl/gotosl/translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ func (st *State) TranslateDir(pf string) error {
kn.Atomics, kn.VarsUsed, nvars = st.VarsUsed(st.KernelFuncs)
maxVarsUsed = max(maxVarsUsed, nvars)
fmt.Printf("###################################\nTranslating Kernel file: %s NVars: %d (atomic: %d)\n", kn.Name, nvars, len(kn.Atomics))
if nvars > 10 { // todo: change when limit is raised to 16
fmt.Println("WARNING: NVars exceeds maxStorageBuffersPerShaderStage min of 10")
if nvars > st.Config.MaxStorageBuffersPerShaderStage {
fmt.Println("WARNING: NVars exceeds maxStorageBuffersPerShaderStage min of:", st.Config.MaxStorageBuffersPerShaderStage)
nOverBase++
}
hdr := st.GenKernelHeader(sy, kn)
Expand Down Expand Up @@ -193,7 +193,7 @@ func (st *State) TranslateDir(pf string) error {
}
fmt.Println("\n###################################\nMaximum number of variables used per shader:", maxVarsUsed)
if nOverBase > 0 {
fmt.Printf("WARNING: %d shaders exceed maxStorageBuffersPerShaderStage min of 10\n", nOverBase)
fmt.Printf("WARNING: %d shaders exceed maxStorageBuffersPerShaderStage min of: %d\n", nOverBase, st.Config.MaxStorageBuffersPerShaderStage)
}

//////// check types
Expand Down
6 changes: 4 additions & 2 deletions gosl/gotosl/typegen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions plot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,3 @@ Here is the copyright notice for that package:
// license that can be found in the LICENSE file.
```

# TODO

* Min / Max not just for extending but also _limiting_ the range -- currently doesn't do

* tensor index
* Grid? in styling.

8 changes: 7 additions & 1 deletion plot/axis.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,15 @@ func (ax *AxisStyle) Defaults() {
// This is the "internal" data structure and should not be used for styling.
type Axis struct {

// Range has the Min, Max range of values for the axis (in raw data units.)
// Range has the full Min, Max range of values for the axis
// (in raw data units). This includes extra space needed for plotting.
Range minmax.F64

// DataRange has the Min, Max range for the actual data values
// for the axis (in raw data units), *exclusive* of extra plotting space.
// This is used for OutOfRange clipping.
DataRange minmax.F64

// specifies which axis this is: X, Y or Z.
Axis math32.Dims

Expand Down
42 changes: 39 additions & 3 deletions plot/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,49 @@ func Range(data Valuer, rng *minmax.F64) {
}
}

// RangeLogic processes the OutOfRange setting to set the given axis range
// based on style range settings (i.e., dealing with Stretch vs. other cases).
// Returns true if the range of the data fits entirely within the styleRng
// min / max values (according to axisRng which must already be updated from data).
func RangeLogic(oor OutOfRange, axisRng *minmax.F64, styleRng *minmax.Range64) bool {
if oor == Stretch {
RangeClamp(axisRng, styleRng)
return true // by definition
}
return RangeSet(axisRng, styleRng)
}

// RangeClamp updates the given axis Min, Max range values based
// on the range of values in the given [Data], and the given style range.
func RangeClamp(data Valuer, axisRng *minmax.F64, styleRng *minmax.Range64) {
Range(data, axisRng)
// on the axis range (from data values), and the given style range.
// The style can only stretch the range, not shrink it.
func RangeClamp(axisRng *minmax.F64, styleRng *minmax.Range64) {
axisRng.Min, axisRng.Max = styleRng.Clamp(axisRng.Min, axisRng.Max)
}

// RangeSet sets the axis range based on the given style range,
// where styleRng flags for Min or Max are set, and otherwise gets the range
// from the axis range (based on actual data).
// This is for the case where the flags indicate a hard,
// non-stretchable extreme, whereas RangeClamp is the stretch case.
// Returns true if the range of the data fits entirely within the styleRng
// min / max values.
func RangeSet(axisRng *minmax.F64, styleRng *minmax.Range64) bool {
fits := true
if styleRng.FixMin {
if axisRng.Min < styleRng.Min {
fits = false
}
axisRng.Min = styleRng.Min
}
if styleRng.FixMax {
if axisRng.Max > styleRng.Max {
fits = false
}
axisRng.Max = styleRng.Max
}
return fits
}

// CheckLengths checks that all the data elements have the same length.
// Logs and returns an error if not.
func (dt Data) CheckLengths() error {
Expand Down
Loading
Loading