Documentation
¶
Overview ¶
Package plots 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.
Unlike the gonum/plot package, NaN values are treated as missing data points, and are just skipped over.
New* functions return an error if the data contains Inf or is empty. Some of the New* functions return other plotter-specific errors too.
Index ¶
- Constants
- type Bar
- func (bc *Bar) ApplyStyle(ps *plot.PlotStyle, idx int)
- func (bc *Bar) BarHeight(i int) float64
- func (bc *Bar) Data() (data plot.Data, pixX, pixY []float32)
- func (bc *Bar) Defaults()
- func (bc *Bar) Plot(plt *plot.Plot)
- func (bc *Bar) StackOn(on *Bar)
- func (bc *Bar) Styler(f func(s *plot.Style)) *Bar
- func (bc *Bar) Stylers() *plot.Stylers
- func (bc *Bar) Thumbnail(plt *plot.Plot)
- func (bc *Bar) UpdateRange(plt *plot.Plot, x, y, yr, z *minmax.F64)
- type Labels
- func (lb *Labels) ApplyStyle(ps *plot.PlotStyle, idx int)
- func (lb *Labels) Data() (data plot.Data, pixX, pixY []float32)
- func (lb *Labels) Defaults()
- func (lb *Labels) Plot(plt *plot.Plot)
- func (lb *Labels) Styler(f func(s *plot.Style)) *Labels
- func (lb *Labels) Stylers() *plot.Stylers
- func (lb *Labels) UpdateRange(plt *plot.Plot, x, y, yr, z *minmax.F64)
- type XErrorBars
- func (eb *XErrorBars) ApplyStyle(ps *plot.PlotStyle, idx int)
- func (eb *XErrorBars) Data() (data plot.Data, pixX, pixY []float32)
- func (eb *XErrorBars) Defaults()
- func (eb *XErrorBars) Plot(plt *plot.Plot)
- func (eb *XErrorBars) Styler(f func(s *plot.Style)) *XErrorBars
- func (eb *XErrorBars) Stylers() *plot.Stylers
- func (eb *XErrorBars) UpdateRange(plt *plot.Plot, x, y, yr, z *minmax.F64)
- type XY
- func (ln *XY) ApplyStyle(ps *plot.PlotStyle, idx int)
- func (ln *XY) Data() (data plot.Data, pixX, pixY []float32)
- func (ln *XY) Defaults()
- func (ln *XY) Plot(plt *plot.Plot)
- func (ln *XY) SetData(data any) error
- func (ln *XY) Styler(f func(s *plot.Style)) *XY
- func (ln *XY) Stylers() *plot.Stylers
- func (ln *XY) Thumbnail(plt *plot.Plot)
- func (ln *XY) UpdateRange(plt *plot.Plot, x, y, yr, z *minmax.F64)
- type YErrorBars
- func (eb *YErrorBars) ApplyStyle(ps *plot.PlotStyle, idx int)
- func (eb *YErrorBars) Data() (data plot.Data, pixX, pixY []float32)
- func (eb *YErrorBars) Defaults()
- func (eb *YErrorBars) Plot(plt *plot.Plot)
- func (eb *YErrorBars) Styler(f func(s *plot.Style)) *YErrorBars
- func (eb *YErrorBars) Stylers() *plot.Stylers
- func (eb *YErrorBars) UpdateRange(plt *plot.Plot, x, y, yr, z *minmax.F64)
Constants ¶
const ( // YErrorBarsType is be used for specifying the type name. YErrorBarsType = "YErrorBars" // XErrorBarsType is be used for specifying the type name. XErrorBarsType = "XErrorBars" )
const BarType = "Bar"
BarType is be used for specifying the type name.
const LabelsType = "Labels"
LabelsType is be used for specifying the type name.
const XYType = "XY"
XYType is be used for specifying the type name.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bar ¶
type Bar struct {
// copies of data
Y, Err plot.Values
// actual plotting X, Y values in data coordinates, taking into account stacking etc.
X, Yp plot.Values
// PX, PY are the actual pixel plotting coordinates for each XY value.
PX, PY []float32
// Style has the properties used to render the bars.
Style plot.Style
// Horizontal dictates whether the bars should be in the vertical
// (default) or horizontal direction. If Horizontal is true, all
// X locations and distances referred to here will actually be Y
// locations and distances.
Horizontal bool
// stackedOn is the bar chart upon which this bar chart is stacked.
StackedOn *Bar
// contains filtered or unexported fields
}
A Bar presents ordinally-organized data with rectangular bars with lengths proportional to the data values, and an optional error bar ("handle") at the top of the bar using the High data role.
Bars are plotted centered at integer multiples of Stride plus Start offset. Full data range also includes Pad value to extend range beyond edge bar centers. Bar Width is in data units, e.g., should be <= Stride. Defaults provide a unit-spaced plot.
func NewBar ¶
NewBar adds a new bar plotter with a single bar for each value, for given data which can either by a plot.Valuer (e.g., Tensor) with the Y values, or a plot.Data with roles, and values defined. The bars heights correspond to the values and their x locations correspond to the index of their value in the Valuer. Optional error-bar values can be provided using the High data role. Styler functions are obtained from the Y metadata if present.
func (*Bar) BarHeight ¶
BarHeight returns the maximum y value of the ith bar, taking into account any bars upon which it is stacked.
func (*Bar) StackOn ¶
StackOn stacks a bar chart on top of another, and sets the bar positioning options to that of the chart upon which it is being stacked.
type Labels ¶
type Labels struct {
// copies of data for this line
X, Y plot.Values
Labels plot.Labels
// PX, PY are the actual pixel plotting coordinates for each XY value.
PX, PY []float32
// Style is the style of the label text.
Style plot.Style
// contains filtered or unexported fields
}
Labels draws text labels at specified X, Y points.
func NewLabels ¶
NewLabels adds a new Labels to given plot for given data, which must specify X, Y and Label roles. Styler functions are obtained from the Label metadata if present.
type XErrorBars ¶
type XErrorBars struct {
// copies of data for this line
X, Y, Low, High plot.Values
// PX, PY are the actual pixel plotting coordinates for each XY value.
PX, PY []float32
// Style is the style for plotting.
Style plot.Style
// contains filtered or unexported fields
}
XErrorBars draws horizontal error bars, denoting error in X values, using ether High or Low, High data roles for error deviations around X, Y coordinates.
func NewXErrorBars ¶
func NewXErrorBars(plt *plot.Plot, data plot.Data) *XErrorBars
NewXErrorBars adds a new XErrorBars plotter to given plot, using Low, High data roles for error deviations around X, Y coordinates.
func (*XErrorBars) ApplyStyle ¶
func (eb *XErrorBars) ApplyStyle(ps *plot.PlotStyle, idx int)
func (*XErrorBars) Defaults ¶
func (eb *XErrorBars) Defaults()
func (*XErrorBars) Plot ¶
func (eb *XErrorBars) Plot(plt *plot.Plot)
func (*XErrorBars) Styler ¶
func (eb *XErrorBars) Styler(f func(s *plot.Style)) *XErrorBars
Styler adds a style function to set style parameters.
func (*XErrorBars) Stylers ¶
func (eb *XErrorBars) Stylers() *plot.Stylers
func (*XErrorBars) UpdateRange ¶
func (eb *XErrorBars) UpdateRange(plt *plot.Plot, x, y, yr, z *minmax.F64)
UpdateRange updates the given ranges.
type XY ¶
type XY struct {
// copies of data for this line
X, Y, Color, Size plot.Values
// PX, PY are the actual pixel plotting coordinates for each XY value.
PX, PY []float32
// Style is the style for plotting.
Style plot.Style
// contains filtered or unexported fields
}
XY draws lines between and / or points for XY data values.
func NewLine ¶
NewLine adds an XY plot drawing Lines only by default, for given data which can either by a plot.Valuer (e.g., Tensor) with the Y values, or a plot.Data with roles, and values defined. See also NewScatter and NewPointLine.
func NewPointLine ¶
NewPointLine adds an XY plot drawing both lines and points by default, for given data which can either by a plot.Valuer (e.g., Tensor) with the Y values, or a plot.Data with roles, and values defined. See also NewLine and NewScatter.
func NewScatter ¶
NewScatter adds an XY scatter plot drawing Points only by default, for given data which can either by a plot.Valuer (e.g., Tensor) with the Y values, or a plot.Data with roles, and values defined. See also NewLine and NewPointLine.
func NewXY ¶
NewXY adds a new XY plotter to given plot for given data, which can either by a plot.Valuer (e.g., Tensor) with the Y values, or a plot.Data with roles, and values defined. Data can also include Color and / or Size for the points. Styler functions are obtained from the Y metadata if present.
type YErrorBars ¶
type YErrorBars struct {
// copies of data for this line
X, Y, Low, High plot.Values
// PX, PY are the actual pixel plotting coordinates for each XY value.
PX, PY []float32
// Style is the style for plotting.
Style plot.Style
// contains filtered or unexported fields
}
YErrorBars draws vertical error bars, denoting error in Y values, using ether High or Low, High data roles for error deviations around X, Y coordinates.
func NewYErrorBars ¶
func NewYErrorBars(plt *plot.Plot, data plot.Data) *YErrorBars
NewYErrorBars adds a new YErrorBars plotter to given plot, using Low, High data roles for error deviations around X, Y coordinates. Styler functions are obtained from the High data if present.
func (*YErrorBars) ApplyStyle ¶
func (eb *YErrorBars) ApplyStyle(ps *plot.PlotStyle, idx int)
func (*YErrorBars) Defaults ¶
func (eb *YErrorBars) Defaults()
func (*YErrorBars) Plot ¶
func (eb *YErrorBars) Plot(plt *plot.Plot)
func (*YErrorBars) Styler ¶
func (eb *YErrorBars) Styler(f func(s *plot.Style)) *YErrorBars
Styler adds a style function to set style parameters.
func (*YErrorBars) Stylers ¶
func (eb *YErrorBars) Stylers() *plot.Stylers
func (*YErrorBars) UpdateRange ¶
func (eb *YErrorBars) UpdateRange(plt *plot.Plot, x, y, yr, z *minmax.F64)
UpdateRange updates the given ranges.