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.
Example (LogScale) ¶
Example_logScale shows how to create a plot with a log-scale on the Y-axis.
Output:
Index ¶
- Variables
- func CheckFloats(fs ...float64) error
- func NewLinePoints(xys XYer) (*Line, *Scatter, error)
- func PaletteThumbnailers(p palette.Palette) []plot.Thumbnailer
- func Range(vs Valuer) (min, max float64)
- func XYRange(xys XYer) (xmin, xmax, ymin, ymax float64)
- type BarChart
- func (b *BarChart) BarHeight(i int) float64
- func (b *BarChart) DataRange() (xmin, xmax, ymin, ymax float64)
- func (b *BarChart) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox
- func (b *BarChart) Plot(c draw.Canvas, plt *plot.Plot)
- func (b *BarChart) StackOn(on *BarChart)
- func (b *BarChart) Thumbnail(c *draw.Canvas)
- type BoxPlot
- type ColorBar
- type Contour
- type Errors
- type Field
- type FieldXY
- type Flow
- type Function
- type GlyphBoxes
- type Grid
- type GridXYZ
- type HeatMap
- type Histogram
- type HistogramBin
- type Image
- type Labeller
- type Labels
- type Line
- type Polygon
- type QuartPlot
- type Sankey
- func (s *Sankey) DataRange() (xmin, xmax, ymin, ymax float64)
- func (s *Sankey) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox
- func (s *Sankey) Plot(c draw.Canvas, plt *plot.Plot)
- func (s *Sankey) StockRange(label string, category int) (min, max float64, err error)
- func (s *Sankey) Thumbnailers() (legendLabels []string, thumbnailers []plot.Thumbnailer)
- type Scatter
- type StepKind
- type ValueLabels
- type Valuer
- type Values
- type XErrorBars
- type XErrorer
- type XErrors
- type XValues
- type XY
- type XYLabeller
- type XYLabels
- type XYValues
- type XYZ
- type XYZer
- type XYZs
- type XYer
- type XYs
- type YErrorBars
- type YErrorer
- type YErrors
- type YValues
Examples ¶
- Package
- Package (InvertedScale)
- Package (LogScale)
- Package (Rotation)
- Package (TimeSeries)
- Package (Volcano)
- BarChart
- BarChart (PositiveNegative)
- BoxPlot
- ColorBar (Horizontal)
- ColorBar (Horizontal_log)
- ColorBar (Vertical)
- Contour
- Errors
- Field
- Field (Colors)
- Field (Gophers)
- Function
- HeatMap
- HeatMap (Rasterized)
- Histogram
- Histogram (LogScaleY)
- Image
- Image (Log)
- Labels
- Labels (InCanvasCoordinates)
- Line (FilledLine)
- Line (StepLine)
- Polygon (Hexagons)
- Polygon (Holes)
- QuartPlot
- Sankey (Grouped)
- Sankey (Simple)
- Scatter
- Scatter (Bubbles)
- Scatter (Color)
Constants ¶
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("plotter: infinite data point") ErrNaN = errors.New("plotter: NaN data point") ErrNoData = errors.New("plotter: 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.
Functions ¶
func CheckFloats ¶
CheckFloats returns an error if any of the arguments are NaN or Infinity.
func NewLinePoints ¶
NewLinePoints returns both a Line and a Points for the given point data.
func PaletteThumbnailers ¶
func PaletteThumbnailers(p palette.Palette) []plot.Thumbnailer
PaletteThumbnailers creates a slice of plot.Thumbnailers that can be used to add legend entries for the colors in a color palette.
Types ¶
type BarChart ¶
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 // 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 // contains filtered or unexported fields }
A BarChart presents grouped data with rectangular bars with lengths proportional to the data values.
Example (PositiveNegative) ¶
This example shows a bar chart with both positive and negative values.
Output:
func NewBarChart ¶
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 ¶
BarHeight returns the maximum y value of the ith bar, taking into account any bars upon which it is stacked.
func (*BarChart) GlyphBoxes ¶
GlyphBoxes implements the GlyphBoxer interface.
type BoxPlot ¶
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 // Horizontal dictates whether the BoxPlot should be in the vertical // (default) or horizontal direction. Horizontal bool // contains filtered or unexported fields }
BoxPlot implements the Plotter interface, drawing a boxplot to represent the distribution of values.
func NewBoxPlot ¶
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 ¶
DataRange returns the minimum and maximum x and y values, implementing the plot.DataRanger interface.
func (*BoxPlot) GlyphBoxes ¶
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 ¶
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.
type ColorBar ¶
type ColorBar struct { ColorMap palette.ColorMap // Vertical determines wether the legend will be // plotted vertically or horizontally. // The default is false (horizontal). Vertical bool // Colors specifies the number of colors to be // shown in the legend. If Colors is not specified, // a default will be used. Colors int }
ColorBar is a plot.Plotter that draws a color bar legend for a ColorMap.
Example (Horizontal_log) ¶
This example shows how to create a ColorBar on a log-transformed axis.
Output:
type Contour ¶
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 ¶
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. If the returned Contour is used when Min is greater than Max, the Plot method will panic.
func (*Contour) DataRange ¶
DataRange implements the DataRange method of the plot.DataRanger interface.
func (*Contour) GlyphBoxes ¶
GlyphBoxes implements the GlyphBoxes method of the plot.GlyphBoxer interface.
type Errors ¶
type Errors []struct{ Low, High float64 }
Errors is a slice of low and high error values.
type Field ¶
type Field struct { FieldXY FieldXY // DrawGlyph is the user hook to draw a field // vector glyph. The function should draw a unit // vector to (1, 0) on the vg.Canvas, c with the // sty LineStyle. The Field plotter will rotate // and scale the unit vector appropriately. // If the magnitude of v is zero, no scaling or // rotation is performed. // // The direction and magnitude of v can be used // to determine properties of the glyph drawing // but should not be used to determine size or // directions of the glyph. // // If DrawGlyph is nil, a simple arrow will be // drawn. DrawGlyph func(c vg.Canvas, sty draw.LineStyle, v XY) // LineStyle is the style of the line used to // render vectors when DrawGlyph is nil. // Otherwise it is passed to DrawGlyph. LineStyle draw.LineStyle // contains filtered or unexported fields }
Field implements the Plotter interface, drawing a vector field of the values in the FieldXY field.
Example ¶
Output:
Example (Colors) ¶
Output:
Example (Gophers) ¶
Output:
func (*Field) DataRange ¶
DataRange implements the DataRange method of the plot.DataRanger interface.
func (*Field) GlyphBoxes ¶
GlyphBoxes implements the GlyphBoxes method of the plot.GlyphBoxer interface.
type FieldXY ¶
type FieldXY interface { // Dims returns the dimensions of the grid. Dims() (c, r int) // Vector returns the value of a vector field at (c, r). // It will panic if c or r are out of bounds for the field. Vector(c, r int) XY // X returns the coordinate for the column at the index c. // 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 }
FieldXY describes a two dimensional vector field where the X and Y coordinates are arranged on a rectangular grid.
type Flow ¶
type Flow struct {
// SourceLabel and ReceptorLabel are the labels
// of the stocks that originate and receive the flow,
// respectively.
SourceLabel, ReceptorLabel string
// SourceCategory and ReceptorCategory define
// the locations on the category axis of the stocks that
// originate and receive the flow, respectively. The
// SourceCategory must be a lower number than
// the ReceptorCategory.
SourceCategory, ReceptorCategory int
// Value represents the magnitute of the flow.
// It must be greater than or equal to zero.
Value float64
// Group specifies the group that a flow belongs
// to. It is used in assigning styles to groups
// and creating legends.
Group string
}
A Flow represents the amount of an entity flowing between two stocks.
type Function ¶
type Function struct { F func(x float64) (y float64) // XMin and XMax specify the range // of x values to pass to F. XMin, XMax float64 Samples int draw.LineStyle }
Function implements the Plotter interface, drawing a line for the given function.
func NewFunction ¶
NewFunction returns a Function that plots F using the default line style with 50 samples.
type GlyphBoxes ¶
GlyphBoxes implements the Plotter interface, drawing all of the glyph boxes of the plot. This is intended for debugging.
func NewGlyphBoxes ¶
func NewGlyphBoxes() *GlyphBoxes
type Grid ¶
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.
type GridXYZ ¶
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 c. // 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 ¶
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 // NaN is the color used to fill heat map elements // that are NaN or do not map to a unique palette // color. NaN color.Color // Min and Max define the dynamic range of the // heat map. Min, Max float64 // Rasterized indicates whether the heatmap // should be produced using raster-based drawing. Rasterized bool }
HeatMap implements the Plotter interface, drawing a heat map of the values in the GridXYZ field.
Example ¶
Output:
Example (Rasterized) ¶
Output:
func NewHeatMap ¶
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. If the returned HeatMap is used when Min is greater than Max, the Plot method will panic.
func (*HeatMap) DataRange ¶
DataRange implements the DataRange method of the plot.DataRanger interface.
func (*HeatMap) GlyphBoxes ¶
GlyphBoxes implements the GlyphBoxes method of the plot.GlyphBoxer interface.
type Histogram ¶
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 // LogY allows rendering with a log-scaled Y axis. // When enabled, histogram bins with no entries will be discarded from // the histogram's DataRange. // The lowest Y value for the DataRange will be corrected to leave an // arbitrary amount of height for the smallest bin entry so it is visible // on the final plot. LogY bool }
Histogram implements the Plotter interface, drawing a histogram of the data.
func NewHist ¶
NewHist returns a new histogram, as in NewHistogram, except that it accepts a Valuer instead of an XYer.
func NewHistogram ¶
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) Normalize ¶
Normalize normalizes the histogram so that the total area beneath it sums to a given value.
type HistogramBin ¶
A HistogramBin approximates the number of values within a range by a single number (the weight).
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image is a plotter that draws a scaled, raster image.
func NewImage ¶
NewImage creates a new image plotter. Image will plot img inside the rectangle defined by the (xmin, ymin) and (xmax, ymax) points given in the data space. The img will be scaled to fit inside the rectangle.
func (*Image) DataRange ¶
DataRange implements the DataRange method of the plot.DataRanger interface.
func (*Image) GlyphBoxes ¶
GlyphBoxes implements the GlyphBoxes method of the plot.GlyphBoxer interface.
type Labels ¶
type Labels struct { XYs // Labels is the set of labels corresponding // to each point. Labels []string // TextStyle is the style of the label text. Each label // can have a different text style. TextStyle []draw.TextStyle // 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.
Example (InCanvasCoordinates) ¶
ExampleLabels_inCanvasCoordinates shows how to write a label in a plot using the canvas coordinates (instead of the data coordinates.) It can be useful in the situation where one wants to draw some label always in the same location of a plot, irrespective of the minute details of a particular plot data range.
Output:
func NewLabels ¶
func NewLabels(d XYLabeller) (*Labels, error)
NewLabels returns a new Labels using the DefaultFont and the DefaultFontSize.
func (*Labels) GlyphBoxes ¶
GlyphBoxes returns a slice of GlyphBoxes, one for each of the labels, implementing the plot.GlyphBoxer interface.
type Line ¶
type Line struct { // XYs is a copy of the points for this line. XYs // StepStyle is the kind of the step line. StepStyle StepKind // LineStyle is the style of the line connecting the points. // Use zero width to disable lines. draw.LineStyle // FillColor is the color to fill the area below the plot. // Use nil to disable the filling. This is the default. FillColor color.Color }
Line implements the Plotter interface, drawing a line.
func (*Line) DataRange ¶
DataRange returns the minimum and maximum x and y values, implementing the plot.DataRanger interface.
type Polygon ¶
type Polygon struct { // XYs is a copy of the vertices of this polygon. // Each item in the array holds one ring in the // Polygon. XYs []XYs // LineStyle is the style of the line around the edge // of the polygon. draw.LineStyle // Color is the fill color of the polygon. Color color.Color }
Polygon implements the Plotter interface, drawing a polygon.
Example (Hexagons) ¶
ExamplePolygon_hexagons creates a heat map with hexagon shapes. The output of this example is at https://github.com/gonum/plot/blob/master/plotter/testdata/polygon_hexagons_golden.png.
Output:
Example (Holes) ¶
ExamplePolygon_holes draws a polygon with holes, showing how the different built-in vg backends render polygons with holes. The output of this example is at https://github.com/gonum/plot/blob/master/plotter/testdata/polygon_holes_golden.png, https://github.com/gonum/plot/blob/master/plotter/testdata/polygon_holes_golden.svg, https://github.com/gonum/plot/blob/master/plotter/testdata/polygon_holes_golden.pdf, and https://github.com/gonum/plot/blob/master/plotter/testdata/polygon_holes_golden.eps.
Output:
func NewPolygon ¶
NewPolygon returns a polygon that uses the default line style and no fill color, where xys are the rings of the polygon. Different backends may render overlapping rings and self-intersections differently, but all built-in backends treat inner rings with the opposite winding order from the outer ring as holes.
func (*Polygon) DataRange ¶
DataRange returns the minimum and maximum x and y values, implementing the plot.DataRanger interface.
type QuartPlot ¶
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 // Horizontal dictates whether the QuartPlot should be in the vertical // (default) or horizontal direction. Horizontal bool // 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 ¶
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 ¶
DataRange returns the minimum and maximum x and y values, implementing the plot.DataRanger interface.
func (*QuartPlot) GlyphBoxes ¶
GlyphBoxes returns a slice of GlyphBoxes for the plot, implementing the plot.GlyphBoxer interface.
func (*QuartPlot) OutsideLabels ¶
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.
type Sankey ¶
type Sankey struct { // Color specifies the default fill // colors for the stocks and flows. If Color is not nil, // each stock and flow is rendered filled with Color, // otherwise no fill is performed. Colors can be // modified for individual stocks and flows. Color color.Color // StockBarWidth is the widths of the bars representing // the stocks. The default value is 15% larger than the // height of the stock label text. StockBarWidth vg.Length // LineStyle specifies the default border // line style for the stocks and flows. Styles can be // modified for individual stocks and flows. LineStyle draw.LineStyle // TextStyle specifies the default stock label // text style. Styles can be modified for // individual stocks. TextStyle draw.TextStyle // FlowStyle is a function that specifies the // background color and border line style of the // flow based on its group name. The default // function uses the default Color and LineStyle // specified above for all groups. FlowStyle func(group string) (color.Color, draw.LineStyle) // StockStyle is a function that specifies, for a stock // identified by its label and category, the label text // to be printed on the plot (lbl), the style of the text (ts), // the horizontal and vertical offsets for printing the text (xOff and yOff), // the color of the fill for the bar representing the stock (c), // and the style of the outline of the bar representing the stock (ls). // The default function uses the default TextStyle, color and LineStyle // specified above for all stocks; zero horizontal and vertical offsets; // and the stock label as the text to be printed on the plot. StockStyle func(label string, category int) (lbl string, ts draw.TextStyle, xOff, yOff vg.Length, c color.Color, ls draw.LineStyle) // contains filtered or unexported fields }
A Sankey diagram presents stock and flow data as rectangles representing the amount of each stock and lines between the stocks representing the amount of each flow.
Example (Grouped) ¶
ExampleSankey_grouped creates a sankey diagram with grouped flows. The output can be found at https://github.com/gonum/plot/blob/master/plotter/testdata/sankeyGrouped_golden.png.
Output:
Example (Simple) ¶
ExampleSankey_sample creates a simple sankey diagram. The output can be found at https://github.com/gonum/plot/blob/master/plotter/testdata/sankeySimple_golden.png.
Output:
func (*Sankey) GlyphBoxes ¶
GlyphBoxes implements the GlyphBoxer interface.
func (*Sankey) StockRange ¶
StockRange returns the minimum and maximum value on the value axis for the stock with the specified label and category.
func (*Sankey) Thumbnailers ¶
func (s *Sankey) Thumbnailers() (legendLabels []string, thumbnailers []plot.Thumbnailer)
Thumbnailers creates a group of objects that can be used to add legend entries for the different flow groups in this diagram, as well as the flow group labels that correspond to them.
type Scatter ¶
type Scatter struct { // XYs is a copy of the points for this scatter. XYs // GlyphStyleFunc, if not nil, specifies GlyphStyles // for individual points GlyphStyleFunc func(int) draw.GlyphStyle // 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.
Example (Bubbles) ¶
ExampleScatter_bubbles draws some scatter points. Each point is plotted with a different radius size depending on external criteria.
Output:
Example (Color) ¶
ExampleScatter_color draws a colored scatter plot. Each point is plotted with a different color depending on external criteria.
Output:
func NewScatter ¶
NewScatter returns a Scatter that uses the default glyph style.
func (*Scatter) DataRange ¶
DataRange returns the minimum and maximum x and y values, implementing the plot.DataRanger interface.
func (*Scatter) GlyphBoxes ¶
GlyphBoxes returns a slice of plot.GlyphBoxes, implementing the plot.GlyphBoxer interface.
type StepKind ¶
type StepKind int
StepKind specifies a form of a connection of two consecutive points.
const ( // NoStep connects two points by simple line NoStep StepKind = iota // PreStep connects two points by following lines: vertical, horizontal. PreStep // MidStep connects two points by following lines: horizontal, vertical, horizontal. // Vertical line is placed in the middle of the interval. MidStep // PostStep connects two points by following lines: horizontal, vertical. PostStep )
type ValueLabels ¶
ValueLabels implements both the Valuer and Labeller interfaces.
func (ValueLabels) Label ¶
func (vs ValueLabels) Label(i int) string
Label returns the label of item i.
func (ValueLabels) Value ¶
func (vs ValueLabels) Value(i int) float64
Value returns the value of item i.
type Valuer ¶
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 ¶
type Values []float64
Values implements the Valuer interface.
func CopyValues ¶
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.
type XErrorBars ¶
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 ¶
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 ¶
func (e *XErrorBars) DataRange() (xmin, xmax, ymin, ymax float64)
DataRange implements the plot.DataRanger interface.
func (*XErrorBars) GlyphBoxes ¶
func (e *XErrorBars) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox
GlyphBoxes implements the plot.GlyphBoxer interface.
type XErrorer ¶
type XErrorer interface { // XError returns two error values for X data. XError(int) (float64, float64) }
XErrorer wraps the XError method.
type XValues ¶
type XValues struct {
XYer
}
XValues implements the Valuer interface, returning the x value from an XYer.
type XYLabeller ¶
XYLabeller combines the XYer and Labeller types.
type XYValues ¶
type XYValues struct{ XYZer }
XYValues implements the XYer interface, returning the x and y values from an XYZer.
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) (float64, float64, float64) // XY returns an x, y pair. XY(int) (float64, float64) }
XYZer wraps the Len and XYZ methods.
type XYZs ¶
type XYZs []XYZ
XYZs implements the XYZer interface using a slice.
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 float64) }
XYer wraps the Len and XY methods.
type XYs ¶
type XYs []XY
XYs implements the XYer interface.
type YErrorBars ¶
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 ¶
func NewYErrorBars(yerrs interface { XYer YErrorer }) (*YErrorBars, error)
NewYErrorBars 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 ¶
func (e *YErrorBars) DataRange() (xmin, xmax, ymin, ymax float64)
DataRange implements the plot.DataRanger interface.
func (*YErrorBars) GlyphBoxes ¶
func (e *YErrorBars) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox
GlyphBoxes implements the plot.GlyphBoxer interface.
type YErrorer ¶
type YErrorer interface { // YError returns two error values for Y data. YError(int) (float64, float64) }
YErrorer wraps the YError method.