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

      Draw the plot logo.

      Output:
      
      
      Example (InvertedScale)
      Output:
      
      
      Example (LogScale)

        Example_logScale shows how to create a plot with a log-scale on the Y-axis.

        Output:
        
        
        Example (Rotation)

          Example_rotation gives some examples of rotating text.

          Output:
          
          
          Example (TimeSeries)

            Example_timeSeries draws a time series.

            Output:
            
            
            Example (Volcano)
            Output:
            
            

            Index

            Examples

            Constants

            This section is empty.

            Variables

            View Source
            var (
            	// DefaultFont is the default font for label text.
            	DefaultFont = plot.DefaultFont
            
            	// DefaultFontSize is the default font.
            	DefaultFontSize = vg.Points(10)
            )
            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("plotter: infinite data point")
            	ErrNaN      = errors.New("plotter: NaN data point")
            	ErrNoData   = errors.New("plotter: no data points")
            )
            View Source
            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,
            	}
            )
            View Source
            var DefaultCapWidth = vg.Points(5)

              DefaultCapWidth is the default width of error bar caps.

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

              Functions

              func CheckFloats

              func CheckFloats(fs ...float64) error

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

                func NewLinePoints

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

                  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.

                    func Range

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

                      Range returns the minimum and maximum values.

                      func XYRange

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

                        XYRange returns the minimum and maximum x and y values.

                        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
                          Output:
                          
                          
                          Example (PositiveNegative)

                            This example shows a bar chart with both positive and negative values.

                            Output:
                            
                            

                            func NewBarChart

                            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

                              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

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

                                  DataRange implements the plot.DataRanger interface.

                                  func (*BarChart) GlyphBoxes

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

                                    GlyphBoxes implements the GlyphBoxer interface.

                                    func (*BarChart) Plot

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

                                      Plot implements the plot.Plotter interface.

                                      func (*BarChart) StackOn

                                      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

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

                                          Thumbnail fulfills the plot.Thumbnailer 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.

                                            Example
                                            Output:
                                            
                                            

                                            func NewBoxPlot

                                            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

                                              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

                                                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

                                                  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

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

                                                      Plot draws the BoxPlot on Canvas c and Plot plt.

                                                      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)
                                                        Output:
                                                        
                                                        
                                                        Example (Horizontal_log)

                                                          This example shows how to create a ColorBar on a log-transformed axis.

                                                          Output:
                                                          
                                                          
                                                          Example (Vertical)
                                                          Output:
                                                          
                                                          

                                                          func (*ColorBar) DataRange

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

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

                                                            func (*ColorBar) Plot

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

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

                                                              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.

                                                                Example
                                                                Output:
                                                                
                                                                

                                                                func NewContour

                                                                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. If the returned Contour is used when Min is greater than Max, the Plot method will panic.

                                                                  func (*Contour) DataRange

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

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

                                                                    func (*Contour) GlyphBoxes

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

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

                                                                      func (*Contour) Plot

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

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

                                                                        type Errors

                                                                        type Errors []struct{ Low, High float64 }

                                                                          Errors is a slice of low and high error values.

                                                                          Example

                                                                            ExampleErrors draws points and error bars.

                                                                            Output:
                                                                            
                                                                            

                                                                            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 NewField

                                                                              func NewField(f FieldXY) *Field

                                                                                NewField creates a new vector field plotter.

                                                                                func (*Field) DataRange

                                                                                func (f *Field) DataRange() (xmin, xmax, ymin, ymax float64)

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

                                                                                  func (*Field) GlyphBoxes

                                                                                  func (f *Field) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

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

                                                                                    func (*Field) Plot

                                                                                    func (f *Field) Plot(c draw.Canvas, plt *plot.Plot)

                                                                                      Plot implements the Plot method of the plot.Plotter 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.

                                                                                            Example

                                                                                              ExampleFunction draws some functions.

                                                                                              Output:
                                                                                              
                                                                                              

                                                                                              func NewFunction

                                                                                              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

                                                                                                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

                                                                                                  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

                                                                                                    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

                                                                                                      func NewGlyphBoxes() *GlyphBoxes

                                                                                                      func (GlyphBoxes) Plot

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

                                                                                                      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.

                                                                                                        func NewGrid

                                                                                                        func NewGrid() *Grid

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

                                                                                                          func (*Grid) Plot

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

                                                                                                            Plot implements the plot.Plotter interface.

                                                                                                            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

                                                                                                                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. If the returned HeatMap is used when Min is greater than Max, the Plot method will panic.

                                                                                                                  func (*HeatMap) DataRange

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

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

                                                                                                                    func (*HeatMap) GlyphBoxes

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

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

                                                                                                                      func (*HeatMap) Plot

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

                                                                                                                        Plot implements the Plot method of the plot.Plotter 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.

                                                                                                                          Example

                                                                                                                            An example of making a histogram.

                                                                                                                            Output:
                                                                                                                            
                                                                                                                            
                                                                                                                            Example (LogScaleY)
                                                                                                                            Output:
                                                                                                                            
                                                                                                                            

                                                                                                                            func NewHist

                                                                                                                            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

                                                                                                                              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

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

                                                                                                                                  DataRange returns the minimum and maximum X and Y values

                                                                                                                                  func (*Histogram) Normalize

                                                                                                                                  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

                                                                                                                                    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

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

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

                                                                                                                                        type HistogramBin

                                                                                                                                        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 Image

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

                                                                                                                                            Image is a plotter that draws a scaled, raster image.

                                                                                                                                            Example

                                                                                                                                              An example of embedding an image in a plot.

                                                                                                                                              Output:
                                                                                                                                              
                                                                                                                                              
                                                                                                                                              Example (Log)

                                                                                                                                                An example of embedding an image in a plot with non-linear axes.

                                                                                                                                                Output:
                                                                                                                                                
                                                                                                                                                

                                                                                                                                                func NewImage

                                                                                                                                                func NewImage(img image.Image, xmin, ymin, xmax, ymax float64) *Image

                                                                                                                                                  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

                                                                                                                                                  func (img *Image) DataRange() (xmin, xmax, ymin, ymax float64)

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

                                                                                                                                                    func (*Image) GlyphBoxes

                                                                                                                                                    func (img *Image) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

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

                                                                                                                                                      func (*Image) Plot

                                                                                                                                                      func (img *Image) Plot(c draw.Canvas, p *plot.Plot)

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

                                                                                                                                                        type Labeller

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

                                                                                                                                                          Labeller wraps the Label methods.

                                                                                                                                                          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
                                                                                                                                                            Output:
                                                                                                                                                            
                                                                                                                                                            
                                                                                                                                                            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) DataRange

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

                                                                                                                                                                  DataRange returns the minimum and maximum X and Y values

                                                                                                                                                                  func (*Labels) GlyphBoxes

                                                                                                                                                                  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

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

                                                                                                                                                                      Plot implements the Plotter interface, drawing labels.

                                                                                                                                                                      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.

                                                                                                                                                                        Example (FilledLine)
                                                                                                                                                                        Output:
                                                                                                                                                                        
                                                                                                                                                                        
                                                                                                                                                                        Example (StepLine)
                                                                                                                                                                        Output:
                                                                                                                                                                        
                                                                                                                                                                        

                                                                                                                                                                        func NewLine

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

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

                                                                                                                                                                          func (*Line) DataRange

                                                                                                                                                                          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

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

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

                                                                                                                                                                              func (*Line) Thumbnail

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

                                                                                                                                                                                Thumbnail returns the thumbnail for the Line, implementing the plot.Thumbnailer 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

                                                                                                                                                                                      func NewPolygon(xys ...XYer) (*Polygon, error)

                                                                                                                                                                                        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

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

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

                                                                                                                                                                                          func (*Polygon) Plot

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

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

                                                                                                                                                                                            func (*Polygon) Thumbnail

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

                                                                                                                                                                                              Thumbnail creates the thumbnail for the Polygon, implementing the plot.Thumbnailer 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".

                                                                                                                                                                                                Example
                                                                                                                                                                                                Output:
                                                                                                                                                                                                
                                                                                                                                                                                                

                                                                                                                                                                                                func NewQuartPlot

                                                                                                                                                                                                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

                                                                                                                                                                                                  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

                                                                                                                                                                                                    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

                                                                                                                                                                                                      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

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

                                                                                                                                                                                                          Plot draws the QuartPlot on Canvas c and Plot plt.

                                                                                                                                                                                                          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 NewSankey

                                                                                                                                                                                                                func NewSankey(flows ...Flow) (*Sankey, error)

                                                                                                                                                                                                                  NewSankey creates a new Sankey diagram with the specified flows and stocks.

                                                                                                                                                                                                                  func (*Sankey) DataRange

                                                                                                                                                                                                                  func (s *Sankey) DataRange() (xmin, xmax, ymin, ymax float64)

                                                                                                                                                                                                                    DataRange implements the plot.DataRanger interface.

                                                                                                                                                                                                                    func (*Sankey) GlyphBoxes

                                                                                                                                                                                                                    func (s *Sankey) GlyphBoxes(plt *plot.Plot) []plot.GlyphBox

                                                                                                                                                                                                                      GlyphBoxes implements the GlyphBoxer interface.

                                                                                                                                                                                                                      func (*Sankey) Plot

                                                                                                                                                                                                                      func (s *Sankey) Plot(c draw.Canvas, plt *plot.Plot)

                                                                                                                                                                                                                        Plot implements the plot.Plotter interface.

                                                                                                                                                                                                                        func (*Sankey) StockRange

                                                                                                                                                                                                                        func (s *Sankey) StockRange(label string, category int) (min, max float64, err error)

                                                                                                                                                                                                                          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

                                                                                                                                                                                                                                ExampleScatter draws some scatter points, a line, and a line with points.

                                                                                                                                                                                                                                Output:
                                                                                                                                                                                                                                
                                                                                                                                                                                                                                
                                                                                                                                                                                                                                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

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

                                                                                                                                                                                                                                      NewScatter returns a Scatter that uses the default glyph style.

                                                                                                                                                                                                                                      func (*Scatter) DataRange

                                                                                                                                                                                                                                      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

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

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

                                                                                                                                                                                                                                          func (*Scatter) Plot

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

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

                                                                                                                                                                                                                                            func (*Scatter) Thumbnail

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

                                                                                                                                                                                                                                              Thumbnail the thumbnail for the Scatter, implementing the plot.Thumbnailer 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

                                                                                                                                                                                                                                                type ValueLabels []struct {
                                                                                                                                                                                                                                                	Value float64
                                                                                                                                                                                                                                                	Label string
                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                  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) Len

                                                                                                                                                                                                                                                    func (vs ValueLabels) Len() int

                                                                                                                                                                                                                                                      Len returns the number of items.

                                                                                                                                                                                                                                                      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

                                                                                                                                                                                                                                                            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) float64

                                                                                                                                                                                                                                                              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.

                                                                                                                                                                                                                                                                      func (*XErrorBars) Plot

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

                                                                                                                                                                                                                                                                        Plot implements the Plotter interface, drawing labels.

                                                                                                                                                                                                                                                                        type XErrorer

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

                                                                                                                                                                                                                                                                          XErrorer wraps the XError method.

                                                                                                                                                                                                                                                                          type XErrors

                                                                                                                                                                                                                                                                          type XErrors Errors

                                                                                                                                                                                                                                                                            XErrors implements the XErrorer interface.

                                                                                                                                                                                                                                                                            func (XErrors) XError

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

                                                                                                                                                                                                                                                                            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) float64

                                                                                                                                                                                                                                                                              type XY

                                                                                                                                                                                                                                                                              type XY struct{ X, Y float64 }

                                                                                                                                                                                                                                                                                XY is an x and y value.

                                                                                                                                                                                                                                                                                type XYLabeller

                                                                                                                                                                                                                                                                                type XYLabeller interface {
                                                                                                                                                                                                                                                                                	XYer
                                                                                                                                                                                                                                                                                	Labeller
                                                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                                                  XYLabeller combines the XYer and Labeller types.

                                                                                                                                                                                                                                                                                  type XYLabels

                                                                                                                                                                                                                                                                                  type XYLabels struct {
                                                                                                                                                                                                                                                                                  	XYs
                                                                                                                                                                                                                                                                                  	Labels []string
                                                                                                                                                                                                                                                                                  }

                                                                                                                                                                                                                                                                                    XYLabels holds XY data with labels. The ith label corresponds to the ith XY.

                                                                                                                                                                                                                                                                                    func (XYLabels) Label

                                                                                                                                                                                                                                                                                    func (l XYLabels) Label(i int) string

                                                                                                                                                                                                                                                                                      Label returns the label for point index i.

                                                                                                                                                                                                                                                                                      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) (float64, float64)

                                                                                                                                                                                                                                                                                          XY implements the XY method of the XYer interface.

                                                                                                                                                                                                                                                                                          type XYZ

                                                                                                                                                                                                                                                                                          type XYZ struct{ X, Y, Z float64 }

                                                                                                                                                                                                                                                                                            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) (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.

                                                                                                                                                                                                                                                                                                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) (float64, float64)

                                                                                                                                                                                                                                                                                                      XY implements the XY method of the XYer interface.

                                                                                                                                                                                                                                                                                                      func (XYZs) XYZ

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

                                                                                                                                                                                                                                                                                                        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 float64)
                                                                                                                                                                                                                                                                                                        }

                                                                                                                                                                                                                                                                                                          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) (float64, float64)

                                                                                                                                                                                                                                                                                                              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.

                                                                                                                                                                                                                                                                                                                      func (*YErrorBars) Plot

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

                                                                                                                                                                                                                                                                                                                        Plot implements the Plotter interface, drawing labels.

                                                                                                                                                                                                                                                                                                                        type YErrorer

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

                                                                                                                                                                                                                                                                                                                          YErrorer wraps the YError method.

                                                                                                                                                                                                                                                                                                                          type YErrors

                                                                                                                                                                                                                                                                                                                          type YErrors Errors

                                                                                                                                                                                                                                                                                                                            YErrors implements the YErrorer interface.

                                                                                                                                                                                                                                                                                                                            func (YErrors) YError

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

                                                                                                                                                                                                                                                                                                                            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) float64