plotter

package
v0.0.0-...-54b116d Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package plotter defines a variety of standard Plotters for the plot package.

Plotters use the primitives provided by the plot package to draw to the data area of a plot. This package provides some standard data styles such as lines, scatter plots, box plots, labels, and more.

New* functions return an error if the data contains Inf, NaN, or is empty. Some of the New* functions return other plotter-specific errors too.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultLineStyle is the default style for drawing
	// lines.
	DefaultLineStyle = draw.LineStyle{
		Color:    color.Black,
		Width:    vg.Points(1),
		Dashes:   []vg.Length{},
		DashOffs: 0,
	}

	// DefaultGlyphStyle is the default style used
	// for gyph marks.
	DefaultGlyphStyle = draw.GlyphStyle{
		Color:  color.Black,
		Radius: vg.Points(2.5),
		Shape:  draw.RingGlyph{},
	}
)
View Source
var (
	ErrInfinity = errors.New("Infinite data point")
	ErrNaN      = errors.New("NaN data point")
	ErrNoData   = errors.New("No data points")
)

Functions

func CheckFloats

func CheckFloats(fs ...float32) error

CheckFloats returns an error if any of the arguments are NaN or Infinity.

func Inf

func Inf(sign int) float32

func IsInf

func IsInf(f float32, sign int) bool

func IsNaN

func IsNaN(sign float32) bool

func Max

func Max(x, y float32) float32

func Min

func Min(x, y float32) float32

func Range

func Range(vs Valuer) (min, max float32)

Range returns the minimum and maximum values.

func XYRange

func XYRange(xys XYer) (xmin, xmax, ymin, ymax float32)

XYRange returns the minimum and maximum x and y values.

Types

type Errors

type Errors []struct{ Low, High float32 }

Errors is a slice of low and high error values.

type Labeller

type Labeller interface {
	// Label returns a label.
	Label(int) string
}

Labeller wraps the Label methods.

type Valuer

type Valuer interface {
	// Len returns the number of values.
	Len() int

	// Value returns a value.
	Value(int) float32
}

Valuer wraps the Len and Value methods.

type Values

type Values []float32

Values implements the Valuer interface.

func CopyValues

func CopyValues(vs Valuer) (Values, error)

CopyValues returns a Values that is a copy of the values from a Valuer, or an error if there are no values, or if one of the copied values is a NaN or Infinity.

func (Values) Len

func (vs Values) Len() int

func (Values) Value

func (vs Values) Value(i int) float32

type XErrorer

type XErrorer interface {
	// XError returns two error values for X data.
	XError(int) (float32, float32)
}

XErrorer wraps the XError method.

type XErrors

type XErrors Errors

XErrors implements the XErrorer interface.

func (XErrors) XError

func (xe XErrors) XError(i int) (float32, float32)

type XValues

type XValues struct {
	XYer
}

XValues implements the Valuer interface, returning the x value from an XYer.

func (XValues) Value

func (xs XValues) Value(i int) float32

type XY

type XY struct{ X, Y float32 }

XY is an x and y value.

type XYValues

type XYValues struct{ XYZer }

XYValues implements the XYer interface, returning the x and y values from an XYZer.

func (XYValues) XY

func (xy XYValues) XY(i int) (float32, float32)

XY implements the XY method of the XYer interface.

type XYZ

type XYZ struct{ X, Y, Z float32 }

XYZ is an x, y and z value.

type XYZer

type XYZer interface {
	// Len returns the number of x, y, z triples.
	Len() int

	// XYZ returns an x, y, z triple.
	XYZ(int) (float32, float32, float32)

	// XY returns an x, y pair.
	XY(int) (float32, float32)
}

XYZer wraps the Len and XYZ methods.

type XYZs

type XYZs []XYZ

XYZs implements the XYZer interface using a slice.

func CopyXYZs

func CopyXYZs(data XYZer) (XYZs, error)

CopyXYZs copies an XYZer.

func (XYZs) Len

func (xyz XYZs) Len() int

Len implements the Len method of the XYZer interface.

func (XYZs) XY

func (xyz XYZs) XY(i int) (float32, float32)

XY implements the XY method of the XYer interface.

func (XYZs) XYZ

func (xyz XYZs) XYZ(i int) (float32, float32, float32)

XYZ implements the XYZ method of the XYZer interface.

type XYer

type XYer interface {
	// Len returns the number of x, y pairs.
	Len() int

	// XY returns an x, y pair.
	XY(int) (x, y float32)
}

XYer wraps the Len and XY methods.

type XYs

type XYs []XY

XYs implements the XYer interface.

func CopyXYs

func CopyXYs(data XYer) (XYs, error)

CopyXYs returns an XYs that is a copy of the x and y values from an XYer, or an error if one of the data points contains a NaN or Infinity.

func (XYs) Len

func (xys XYs) Len() int

func (XYs) XY

func (xys XYs) XY(i int) (float32, float32)

type YErrorer

type YErrorer interface {
	// YError returns two error values for Y data.
	YError(int) (float32, float32)
}

YErrorer wraps the YError method.

type YErrors

type YErrors Errors

YErrors implements the YErrorer interface.

func (YErrors) YError

func (ye YErrors) YError(i int) (float32, float32)

type YValues

type YValues struct {
	XYer
}

YValues implements the Valuer interface, returning the y value from an XYer.

func (YValues) Value

func (ys YValues) Value(i int) float32

Jump to

Keyboard shortcuts

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