plotter

package
v0.0.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package plotter is a function plotter: type a formula of x and see its graph.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewForm

func NewForm() *ui.Form

NewForm returns the Function Plotter: a formula typed into an EditableComboBox (with presets and history) is parsed and drawn on a Chart, with the parse errors in a red Label. Sliders change the parameters a and b, NumBoxes the range and the number of points; the "Animate" ToggleSwitch sweeps b with a widget timer. A Table shows a few values (with a context menu to copy them), and "Export CSV..." saves the curve via the system save dialog.

Types

type Formula

type Formula struct {
	// contains filtered or unexported fields
}

Formula is a parsed expression of x and the parameters a and b.

func Parse

func Parse(src string) (*Formula, error)

Parse parses a formula such as "a*sin(b*x) + x^2/10". It knows + - * / ^, unary minus, parentheses, the variables x, a, b, the constants pi and e, and the functions sin cos tan sqrt abs exp ln log floor.

func (*Formula) Eval

func (f *Formula) Eval(v Vars) float64

Eval computes the formula; the result is NaN or ±Inf where the function is not defined (sqrt(-1), 1/0).

type Plotter

type Plotter struct {
	ui.Widget
	// contains filtered or unexported fields
}

Plotter is the main window's content.

type Vars

type Vars struct {
	X, A, B float64
}

Vars are the values a formula is evaluated with.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL