plot: github.com/sksullivan/plot/plotter Index | Files

package plotter

import "github.com/sksullivan/plot/plotter"

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

Package Files

barchart.go boxplot.go bubbles.go conrec.go contour.go errbars.go functions.go glyphbox.go grid.go heat.go histogram.go johnson.go labels.go line.go plotter.go quartile.go scatter.go

Variables

var (
    // DefaultFont is the default font for label text.
    DefaultFont = plot.DefaultFont

    // DefaultFontSize is the default font.
    DefaultFontSize = vg.Points(10)
)
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{},
    }
)
var (
    ErrInfinity = errors.New("Infinite data point")
    ErrNaN      = errors.New("NaN data point")
    ErrNoData   = errors.New("No data points")
)
var (
    // DefaultQuartMedianStyle is a fat dot.
    DefaultQuartMedianStyle = draw.GlyphStyle{
        Color:  color.Black,
        Radius: vg.Points(1.5),
        Shape:  draw.CircleGlyph{},
    }

    // DefaultQuartWhiskerStyle is a hairline.
    DefaultQuartWhiskerStyle = draw.LineStyle{
        Color:    color.Black,
        Width:    vg.Points(0.5),
        Dashes:   []vg.Length{},
        DashOffs: 0,
    }
)
var DefaultCapWidth = vg.Points(5)

DefaultCapWidth is the default width of error bar caps.

var (
    // DefaultGridLineStyle is the default style for grid lines.
    DefaultGridLineStyle = draw.LineStyle{
        Color: color.Gray{128},
        Width: vg.Points(0.25),
    }
)

func CheckFloats Uses

func CheckFloats(fs ...float64) error

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

func Range Uses

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

Range returns the minimum and maximum values.

func XYRange Uses

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

XYRange returns the minimum and maximum x and y values.

type BarChart Uses

type BarChart struct {
    Values

    // Width is the width of the bars.
    Width vg.Length

    // Color is the fill color of the bars.
    Color color.Color

    // LineStyle is the style of the outline of the bars.
    draw.LineStyle

    // Offset is added to the x location of each bar.
    // When the Offset is zero, the bars are drawn
    // centered at their x location.
    Offset vg.Length

    // XMin is the X location of the first bar.  XMin
    // can be changed to move groups of bars
    // down the X axis in order to make grouped
    // bar charts.
    XMin float64
    // contains filtered or unexported fields
}

func NewBarChart Uses

func NewBarChart(vs Valuer, width vg.Length) (*BarChart, error)

NewBarChart returns a new bar chart with a single bar for each value. The bars heights correspond to the values and their x locations correspond to the index of their value in the Valuer.

func (*BarChart) BarHeight Uses

func (b *BarChart) BarHeight(i int) float64

BarHeight returns the maximum y value of the ith bar, taking into account any bars upon which it is stacked.

func (*BarChart) DataRange Uses

func (b *BarChart) DataRange() (xmin, xmax, ymin, ymax float64)

DataRange implements the plot.DataRanger interface.

func (*BarChart) GlyphBoxes Uses

func (b *BarChart) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes implements the GlyphBoxer interface.

func (*BarChart) Plot Uses

func (b *BarChart) Plot(c draw.Canvas, plt *plot.Plot)

Plot implements the plot.Plotter interface.

func (*BarChart) StackOn Uses

func (b *BarChart) StackOn(on *BarChart)

StackOn stacks a bar chart on top of another, and sets the XMin and Offset to that of the chart upon which it is being stacked.

func (*BarChart) Thumbnail Uses

func (b *BarChart) Thumbnail(c *draw.Canvas)

type BoxPlot Uses

type BoxPlot struct {

    // Offset is added to the x location of each box.
    // When the Offset is zero, the boxes are drawn
    // centered at their x location.
    Offset vg.Length

    // Width is the width used to draw the box.
    Width vg.Length

    // CapWidth is the width of the cap used to top
    // off a whisker.
    CapWidth vg.Length

    // GlyphStyle is the style of the outside point glyphs.
    GlyphStyle draw.GlyphStyle

    // BoxStyle is the line style for the box.
    BoxStyle draw.LineStyle

    // MedianStyle is the line style for the median line.
    MedianStyle draw.LineStyle

    // WhiskerStyle is the line style used to draw the
    // whiskers.
    WhiskerStyle draw.LineStyle
    // contains filtered or unexported fields
}

BoxPlot implements the Plotter interface, drawing a boxplot to represent the distribution of values.

func NewBoxPlot Uses

func NewBoxPlot(w vg.Length, loc float64, values Valuer) (*BoxPlot, error)

NewBoxPlot returns a new BoxPlot that represents the distribution of the given values. The style of the box plot is that used for Tukey's schematic plots is “Exploratory Data Analysis.”

An error is returned if the boxplot is created with no values.

The fence values are 1.5x the interquartile before the first quartile and after the third quartile. Any value that is outside of the fences are drawn as Outside points. The adjacent values (to which the whiskers stretch) are the minimum and maximum values that are not outside the fences.

func (*BoxPlot) DataRange Uses

func (b *BoxPlot) DataRange() (float64, float64, float64, float64)

DataRange returns the minimum and maximum x and y values, implementing the plot.DataRanger interface.

func (*BoxPlot) GlyphBoxes Uses

func (b *BoxPlot) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a slice of GlyphBoxes for the points and for the median line of the boxplot, implementing the plot.GlyphBoxer interface

func (*BoxPlot) OutsideLabels Uses

func (b *BoxPlot) OutsideLabels(labels Labeller) (*Labels, error)

OutsideLabels returns a *Labels that will plot a label for each of the outside points. The labels are assumed to correspond to the points used to create the box plot.

func (*BoxPlot) Plot Uses

func (b *BoxPlot) Plot(c draw.Canvas, plt *plot.Plot)

type Bubbles Uses

type Bubbles struct {
    XYZs

    // Color is the color of the bubbles.
    color.Color

    // MinRadius and MaxRadius give the minimum
    // and maximum bubble radius respectively.
    // The radii of each bubble is interpolated linearly
    // between these two values.
    MinRadius, MaxRadius vg.Length

    // MinZ and MaxZ are the minimum and
    // maximum Z values from the data.
    MinZ, MaxZ float64
}

Bubbles implements the Plotter interface, drawing a bubble plot of x, y, z triples where the z value determines the radius of the bubble.

func NewBubbles Uses

func NewBubbles(xyz XYZer, min, max vg.Length) (*Bubbles, error)

NewBubbles creates as new bubble plot plotter for the given data, with a minimum and maximum bubble radius.

func (*Bubbles) DataRange Uses

func (bs *Bubbles) DataRange() (xmin, xmax, ymin, ymax float64)

DataRange implements the DataRange method of the plot.DataRanger interface.

func (*Bubbles) GlyphBoxes Uses

func (bs *Bubbles) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes implements the GlyphBoxes method of the plot.GlyphBoxer interface.

func (*Bubbles) Plot Uses

func (bs *Bubbles) Plot(c draw.Canvas, plt *plot.Plot)

Plot implements the Plot method of the plot.Plotter interface.

type Contour Uses

type Contour struct {
    GridXYZ GridXYZ

    // Levels describes the contour heights to plot.
    Levels []float64

    // LineStyles is the set of styles for contour
    // lines. Line styles are are applied to each level
    // in order, modulo the length of LineStyles.
    LineStyles []draw.LineStyle

    // Palette is the color palette used to render
    // the heat map. If Palette is nil or has no
    // defined color, the Contour LineStyle color
    // is used.
    Palette palette.Palette

    // Underflow and Overflow are colors used to draw
    // contours outside the dynamic range defined
    // by Min and Max.
    Underflow color.Color
    Overflow  color.Color

    // Min and Max define the dynamic range of the
    // heat map.
    Min, Max float64
}

Contour implements the Plotter interface, drawing a contour plot of the values in the GridXYZ field.

func NewContour Uses

func NewContour(g GridXYZ, levels []float64, p palette.Palette) *Contour

NewContour creates as new contour plotter for the given data, using the provided palette. If levels is nil, contours are generated for the 0.01, 0.05, 0.25, 0.5, 0.75, 0.95 and 0.99 quantiles. If g has Min and Max methods that return a float, those returned values are used to set the respective Contour fields.

func (*Contour) DataRange Uses

func (h *Contour) DataRange() (xmin, xmax, ymin, ymax float64)

DataRange implements the DataRange method of the plot.DataRanger interface.

func (*Contour) GlyphBoxes Uses

func (h *Contour) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes implements the GlyphBoxes method of the plot.GlyphBoxer interface.

func (*Contour) Plot Uses

func (h *Contour) Plot(c draw.Canvas, plt *plot.Plot)

Plot implements the Plot method of the plot.Plotter interface.

type Errors Uses

type Errors []struct{ Low, High float64 }

Errors is a slice of low and high error values.

type Function Uses

type Function struct {
    F       func(float64) float64
    Samples int
    draw.LineStyle
}

Function implements the Plotter interface, drawing a line for the given function.

func NewFunction Uses

func NewFunction(f func(float64) float64) *Function

NewFunction returns a Function that plots F using the default line style with 50 samples.

func (*Function) Plot Uses

func (f *Function) Plot(c draw.Canvas, p *plot.Plot)

Plot implements the Plotter interface, drawing a line that connects each point in the Line.

func (Function) Thumbnail Uses

func (f Function) Thumbnail(c *draw.Canvas)

Thumbnail draws a line in the given style down the center of a DrawArea as a thumbnail representation of the LineStyle of the function.

type GlyphBoxes Uses

type GlyphBoxes struct {
    draw.LineStyle
}

GlyphBoxes implements the Plotter interface, drawing all of the glyph boxes of the plot. This is intended for debugging.

func NewGlyphBoxes Uses

func NewGlyphBoxes() *GlyphBoxes

func (GlyphBoxes) Plot Uses

func (g GlyphBoxes) Plot(c draw.Canvas, plt *plot.Plot)

type Grid Uses

type Grid struct {
    // Vertical is the style of the vertical lines.
    Vertical draw.LineStyle

    // Horizontal is the style of the horizontal lines.
    Horizontal draw.LineStyle
}

Grid implements the plot.Plotter interface, drawing a set of grid lines at the major tick marks.

func NewGrid Uses

func NewGrid() *Grid

NewGrid returns a new grid with both vertical and horizontal lines using the default grid line style.

func (*Grid) Plot Uses

func (g *Grid) Plot(c draw.Canvas, plt *plot.Plot)

Plot implements the plot.Plotter interface.

type GridXYZ Uses

type GridXYZ interface {
    // Dims returns the dimensions of the grid.
    Dims() (c, r int)

    // Z returns the value of a grid value at (c, r).
    // It will panic if c or r are out of bounds for the grid.
    Z(c, r int) float64

    // X returns the coordinate for the column at the index x.
    // It will panic if c is out of bounds for the grid.
    X(c int) float64

    // Y returns the coordinate for the row at the index r.
    // It will panic if r is out of bounds for the grid.
    Y(r int) float64
}

GridXYZ describes three dimensional data where the X and Y coordinates are arranged on a rectangular grid.

type HeatMap Uses

type HeatMap struct {
    GridXYZ GridXYZ

    // Palette is the color palette used to render
    // the heat map. Palette must not be nil or
    // return a zero length []color.Color.
    Palette palette.Palette

    // Underflow and Overflow are colors used to fill
    // heat map elements outside the dynamic range
    // defined by Min and Max.
    Underflow color.Color
    Overflow  color.Color

    // Min and Max define the dynamic range of the
    // heat map.
    Min, Max float64
}

HeatMap implements the Plotter interface, drawing a heat map of the values in the GridXYZ field.

func NewHeatMap Uses

func NewHeatMap(g GridXYZ, p palette.Palette) *HeatMap

NewHeatMap creates as new heat map plotter for the given data, using the provided palette. If g has Min and Max methods that return a float, those returned values are used to set the respective HeatMap fields.

func (*HeatMap) DataRange Uses

func (h *HeatMap) DataRange() (xmin, xmax, ymin, ymax float64)

DataRange implements the DataRange method of the plot.DataRanger interface.

func (*HeatMap) GlyphBoxes Uses

func (h *HeatMap) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes implements the GlyphBoxes method of the plot.GlyphBoxer interface.

func (*HeatMap) Plot Uses

func (h *HeatMap) Plot(c draw.Canvas, plt *plot.Plot)

Plot implements the Plot method of the plot.Plotter interface.

type Histogram Uses

type Histogram struct {
    // Bins is the set of bins for this histogram.
    Bins []HistogramBin

    // Width is the width of each bin.
    Width float64

    // FillColor is the color used to fill each
    // bar of the histogram.  If the color is nil
    // then the bars are not filled.
    FillColor color.Color

    // LineStyle is the style of the outline of each
    // bar of the histogram.
    draw.LineStyle
}

Histogram implements the Plotter interface, drawing a histogram of the data.

func NewHist Uses

func NewHist(vs Valuer, n int) (*Histogram, error)

NewHist returns a new histogram, as in NewHistogram, except that it accepts a Valuer instead of an XYer.

func NewHistogram Uses

func NewHistogram(xy XYer, n int) (*Histogram, error)

NewHistogram returns a new histogram that represents the distribution of values using the given number of bins.

Each y value is assumed to be the frequency count for the corresponding x.

If the number of bins is non-positive than a reasonable default is used.

func (*Histogram) DataRange Uses

func (h *Histogram) DataRange() (xmin, xmax, ymin, ymax float64)

DataRange returns the minimum and maximum X and Y values

func (*Histogram) Normalize Uses

func (h *Histogram) Normalize(sum float64)

Normalize normalizes the histogram so that the total area beneath it sums to a given value.

func (*Histogram) Plot Uses

func (h *Histogram) Plot(c draw.Canvas, p *plot.Plot)

Plot implements the Plotter interface, drawing a line that connects each point in the Line.

func (*Histogram) Thumbnail Uses

func (h *Histogram) Thumbnail(c *draw.Canvas)

Thumbnail draws a rectangle in the given style of the histogram.

type HistogramBin Uses

type HistogramBin struct {
    Min, Max float64
    Weight   float64
}

A HistogramBin approximates the number of values within a range by a single number (the weight).

type HorizBoxPlot Uses

type HorizBoxPlot struct{ *BoxPlot }

HorizBoxPlot is like a regular BoxPlot, however, it draws horizontally instead of Vertically.

func MakeHorizBoxPlot Uses

func MakeHorizBoxPlot(w vg.Length, loc float64, vs Valuer) (HorizBoxPlot, error)

MakeHorizBoxPlot returns a HorizBoxPlot, plotting the values in a horizontal box plot centered along a fixed location of the y axis.

func (HorizBoxPlot) DataRange Uses

func (b HorizBoxPlot) DataRange() (float64, float64, float64, float64)

DataRange returns the minimum and maximum x and y values, implementing the plot.DataRanger interface.

func (HorizBoxPlot) GlyphBoxes Uses

func (b HorizBoxPlot) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a slice of GlyphBoxes for the points and for the median line of the boxplot, implementing the plot.GlyphBoxer interface

func (*HorizBoxPlot) OutsideLabels Uses

func (b *HorizBoxPlot) OutsideLabels(labels Labeller) (*Labels, error)

OutsideLabels returns a *Labels that will plot a label for each of the outside points. The labels are assumed to correspond to the points used to create the box plot.

func (HorizBoxPlot) Plot Uses

func (b HorizBoxPlot) Plot(c draw.Canvas, plt *plot.Plot)

type HorizQuartPlot Uses

type HorizQuartPlot struct{ *QuartPlot }

HorizQuartPlot is like a regular QuartPlot, however, it draws horizontally instead of Vertically.

func MakeHorizQuartPlot Uses

func MakeHorizQuartPlot(loc float64, vs Valuer) (HorizQuartPlot, error)

MakeHorizQuartPlot returns a HorizQuartPlot, plotting the values in a horizontal plot centered along a fixed location of the y axis.

func (HorizQuartPlot) DataRange Uses

func (b HorizQuartPlot) DataRange() (float64, float64, float64, float64)

DataRange returns the minimum and maximum x and y values, implementing the plot.DataRanger interface.

func (HorizQuartPlot) GlyphBoxes Uses

func (b HorizQuartPlot) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a slice of GlyphBoxes for the plot, implementing the plot.GlyphBoxer interface.

func (*HorizQuartPlot) OutsideLabels Uses

func (b *HorizQuartPlot) OutsideLabels(labels Labeller) (*Labels, error)

OutsideLabels returns a *Labels that will plot a label for each of the outside points. The labels are assumed to correspond to the points used to create the plot.

func (HorizQuartPlot) Plot Uses

func (b HorizQuartPlot) Plot(c draw.Canvas, plt *plot.Plot)

type Labeller Uses

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

Labeller wraps the Label methods.

type Labels Uses

type Labels struct {
    XYs

    // Labels is the set of labels corresponding
    // to each point.
    Labels []string

    // TextStyle is the style of the label text.
    draw.TextStyle

    // XAlign and YAlign are multiplied by the width
    // and height of each label respectively and the
    // added to the final location.  E.g., XAlign=-0.5
    // and YAlign=-0.5 centers the label at the given
    // X, Y location, and XAlign=0, YAlign=0 aligns
    // the text to the left of the point, and XAlign=-1,
    // YAlign=0 aligns the text to the right of the point.
    XAlign, YAlign float64

    // XOffset and YOffset are added directly to the final
    // label X and Y location respectively.
    XOffset, YOffset vg.Length
}

Labels implements the Plotter interface, drawing a set of labels at specified points.

func NewLabels Uses

func NewLabels(d interface {
    XYer
    Labeller
}) (*Labels, error)

NewLabels returns a new Labels using the DefaultFont and the DefaultFontSize.

func (*Labels) DataRange Uses

func (l *Labels) DataRange() (xmin, xmax, ymin, ymax float64)

DataRange returns the minimum and maximum X and Y values

func (*Labels) GlyphBoxes Uses

func (l *Labels) GlyphBoxes(p *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a slice of GlyphBoxes, one for each of the labels, implementing the plot.GlyphBoxer interface.

func (*Labels) Plot Uses

func (l *Labels) Plot(c draw.Canvas, p *plot.Plot)

Plot implements the Plotter interface, drawing labels.

type Line Uses

type Line struct {
    // XYs is a copy of the points for this line.
    XYs

    // LineStyle is the style of the line connecting
    // the points.
    draw.LineStyle

    // ShadeColor is the color of the shaded area.
    ShadeColor *color.Color
}

Line implements the Plotter interface, drawing a line.

func NewLine Uses

func NewLine(xys XYer) (*Line, error)

NewLine returns a Line that uses the default line style and does not draw glyphs.

func NewLinePoints Uses

func NewLinePoints(xys XYer) (*Line, *Scatter, error)

NewLinePoints returns both a Line and a Points for the given point data.

func (*Line) DataRange Uses

func (pts *Line) DataRange() (xmin, xmax, ymin, ymax float64)

DataRange returns the minimum and maximum x and y values, implementing the plot.DataRanger interface.

func (*Line) Plot Uses

func (pts *Line) Plot(c draw.Canvas, plt *plot.Plot)

Plot draws the Line, implementing the plot.Plotter interface.

func (*Line) Thumbnail Uses

func (pts *Line) Thumbnail(c *draw.Canvas)

Thumbnail the thumbnail for the Line, implementing the plot.Thumbnailer interface.

type QuartPlot Uses

type QuartPlot struct {

    // Offset is added to the x location of each plot.
    // When the Offset is zero, the plot is drawn
    // centered at its x location.
    Offset vg.Length

    // MedianStyle is the line style for the median point.
    MedianStyle draw.GlyphStyle

    // WhiskerStyle is the line style used to draw the
    // whiskers.
    WhiskerStyle draw.LineStyle
    // contains filtered or unexported fields
}

QuartPlot implements the Plotter interface, drawing a plot to represent the distribution of values.

This style of the plot appears in Tufte's "The Visual Display of Quantitative Information".

func NewQuartPlot Uses

func NewQuartPlot(loc float64, values Valuer) (*QuartPlot, error)

NewQuartPlot returns a new QuartPlot that represents the distribution of the given values.

An error is returned if the plot is created with no values.

The fence values are 1.5x the interquartile before the first quartile and after the third quartile. Any value that is outside of the fences are drawn as Outside points. The adjacent values (to which the whiskers stretch) are the minimum and maximum values that are not outside the fences.

func (*QuartPlot) DataRange Uses

func (b *QuartPlot) DataRange() (float64, float64, float64, float64)

DataRange returns the minimum and maximum x and y values, implementing the plot.DataRanger interface.

func (*QuartPlot) GlyphBoxes Uses

func (b *QuartPlot) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a slice of GlyphBoxes for the plot, implementing the plot.GlyphBoxer interface.

func (*QuartPlot) OutsideLabels Uses

func (b *QuartPlot) OutsideLabels(labels Labeller) (*Labels, error)

OutsideLabels returns a *Labels that will plot a label for each of the outside points. The labels are assumed to correspond to the points used to create the plot.

func (*QuartPlot) Plot Uses

func (b *QuartPlot) Plot(c draw.Canvas, plt *plot.Plot)

type Scatter Uses

type Scatter struct {
    // XYs is a copy of the points for this scatter.
    XYs

    // GlyphStyle is the style of the glyphs drawn
    // at each point.
    draw.GlyphStyle
}

Scatter implements the Plotter interface, drawing a glyph for each of a set of points.

func NewScatter Uses

func NewScatter(xys XYer) (*Scatter, error)

NewScatter returns a Scatter that uses the default glyph style.

func (*Scatter) DataRange Uses

func (pts *Scatter) DataRange() (xmin, xmax, ymin, ymax float64)

DataRange returns the minimum and maximum x and y values, implementing the plot.DataRanger interface.

func (*Scatter) GlyphBoxes Uses

func (pts *Scatter) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes returns a slice of plot.GlyphBoxes, implementing the plot.GlyphBoxer interface.

func (*Scatter) Plot Uses

func (pts *Scatter) Plot(c draw.Canvas, plt *plot.Plot)

Plot draws the Scatter, implementing the plot.Plotter interface.

func (*Scatter) Thumbnail Uses

func (pts *Scatter) Thumbnail(c *draw.Canvas)

Thumbnail the thumbnail for the Scatter, implementing the plot.Thumbnailer interface.

type Valuer Uses

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

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

Valuer wraps the Len and Value methods.

type Values Uses

type Values []float64

Values implements the Valuer interface.

func CopyValues Uses

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 Uses

func (vs Values) Len() int

func (Values) Value Uses

func (vs Values) Value(i int) float64

type XErrorBars Uses

type XErrorBars struct {
    XYs

    // XErrors is a copy of the X errors for each point.
    XErrors

    // LineStyle is the style used to draw the error bars.
    draw.LineStyle

    // CapWidth is the width of the caps drawn at the top
    // of each error bar.
    CapWidth vg.Length
}

XErrorBars implements the plot.Plotter, plot.DataRanger, and plot.GlyphBoxer interfaces, drawing horizontal error bars, denoting error in Y values.

func NewXErrorBars Uses

func NewXErrorBars(xerrs interface {
    XYer
    XErrorer
}) (*XErrorBars, error)

Returns a new XErrorBars plotter, or an error on failure. The error values from the XErrorer interface are interpreted as relative to the corresponding X value. The errors for a given X value are computed by taking the absolute value of the error returned by the XErrorer and subtracting the first and adding the second to the X value.

func (*XErrorBars) DataRange Uses

func (e *XErrorBars) DataRange() (xmin, xmax, ymin, ymax float64)

DataRange implements the plot.DataRanger interface.

func (*XErrorBars) GlyphBoxes Uses

func (e *XErrorBars) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes implements the plot.GlyphBoxer interface.

func (*XErrorBars) Plot Uses

func (e *XErrorBars) Plot(c draw.Canvas, p *plot.Plot)

Plot implements the Plotter interface, drawing labels.

type XErrorer Uses

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

XErrorer wraps the XError method.

type XErrors Uses

type XErrors Errors

XErrors implements the XErrorer interface.

func (XErrors) XError Uses

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

type XValues Uses

type XValues struct {
    XYer
}

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

func (XValues) Value Uses

func (xs XValues) Value(i int) float64

type XYValues Uses

type XYValues struct{ XYZer }

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

func (XYValues) XY Uses

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

XY implements the XY method of the XYer interface.

type XYZer Uses

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

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

XYZer wraps the Len and XYZ methods.

type XYZs Uses

type XYZs []struct{ X, Y, Z float64 }

XYZs implements the XYZer interface using a slice.

func CopyXYZs Uses

func CopyXYZs(data XYZer) (XYZs, error)

CopyXYZs copies an XYZer.

func (XYZs) Len Uses

func (xyz XYZs) Len() int

Len implements the Len method of the XYZer interface.

func (XYZs) XYZ Uses

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

XYZ implements the XYZ method of the XYZer interface.

type XYer Uses

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

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

XYer wraps the Len and XY methods.

type XYs Uses

type XYs []struct{ X, Y float64 }

XYs implements the XYer interface.

func CopyXYs Uses

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 Uses

func (xys XYs) Len() int

func (XYs) XY Uses

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

type YErrorBars Uses

type YErrorBars struct {
    XYs

    // YErrors is a copy of the Y errors for each point.
    YErrors

    // LineStyle is the style used to draw the error bars.
    draw.LineStyle

    // CapWidth is the width of the caps drawn at the top
    // of each error bar.
    CapWidth vg.Length
}

YErrorBars implements the plot.Plotter, plot.DataRanger, and plot.GlyphBoxer interfaces, drawing vertical error bars, denoting error in Y values.

func NewYErrorBars Uses

func NewYErrorBars(yerrs interface {
    XYer
    YErrorer
}) (*YErrorBars, error)

Returns a new YErrorBars plotter, or an error on failure. The error values from the YErrorer interface are interpreted as relative to the corresponding Y value. The errors for a given Y value are computed by taking the absolute value of the error returned by the YErrorer and subtracting the first and adding the second to the Y value.

func (*YErrorBars) DataRange Uses

func (e *YErrorBars) DataRange() (xmin, xmax, ymin, ymax float64)

DataRange implements the plot.DataRanger interface.

func (*YErrorBars) GlyphBoxes Uses

func (e *YErrorBars) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

GlyphBoxes implements the plot.GlyphBoxer interface.

func (*YErrorBars) Plot Uses

func (e *YErrorBars) Plot(c draw.Canvas, p *plot.Plot)

Plot implements the Plotter interface, drawing labels.

type YErrorer Uses

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

YErrorer wraps the YError method.

type YErrors Uses

type YErrors Errors

YErrors implements the YErrorer interface.

func (YErrors) YError Uses

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

type YValues Uses

type YValues struct {
    XYer
}

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

func (YValues) Value Uses

func (ys YValues) Value(i int) float64

Package plotter imports 9 packages (graph) and is imported by 2 packages. Updated 2016-08-04. Refresh now. Tools for package owners.