Documentation

Overview

    Package plotutil contains a small number of utilites for creating plots.

    This package is under active development so portions of it may change.

    Index

    Examples

    Constants

    This section is empty.

    Variables

    View Source
    var DarkColors = []color.Color{
    	rgb(238, 46, 47),
    	rgb(0, 140, 72),
    	rgb(24, 90, 169),
    	rgb(244, 125, 35),
    	rgb(102, 44, 145),
    	rgb(162, 29, 33),
    	rgb(180, 56, 148),
    }
    View Source
    var DefaultColors = SoftColors

      DefaultColors is a set of colors used by the Color function.

      View Source
      var DefaultDashes = [][]vg.Length{
      	{},
      
      	{vg.Points(6), vg.Points(2)},
      
      	{vg.Points(2), vg.Points(2)},
      
      	{vg.Points(1), vg.Points(1)},
      
      	{vg.Points(5), vg.Points(2), vg.Points(1), vg.Points(2)},
      
      	{vg.Points(10), vg.Points(2), vg.Points(2), vg.Points(2),
      		vg.Points(2), vg.Points(2), vg.Points(2), vg.Points(2)},
      
      	{vg.Points(10), vg.Points(2), vg.Points(2), vg.Points(2)},
      
      	{vg.Points(5), vg.Points(2), vg.Points(5), vg.Points(2),
      		vg.Points(2), vg.Points(2), vg.Points(2), vg.Points(2)},
      
      	{vg.Points(4), vg.Points(2), vg.Points(4), vg.Points(1),
      		vg.Points(1), vg.Points(1), vg.Points(1), vg.Points(1),
      		vg.Points(1), vg.Points(1)},
      }

        DefaultDashes is a set of dash patterns used by the Dashes function.

          DefaultGlyphShapes is a set of GlyphDrawers used by the Shape function.

          View Source
          var SoftColors = []color.Color{
          	rgb(241, 90, 96),
          	rgb(122, 195, 106),
          	rgb(90, 155, 212),
          	rgb(250, 167, 91),
          	rgb(158, 103, 171),
          	rgb(206, 112, 88),
          	rgb(215, 127, 180),
          }

          Functions

          func AddBoxPlots

          func AddBoxPlots(plt *plot.Plot, width vg.Length, vs ...interface{}) error

            AddBoxPlots adds box plot plotters to a plot and sets the X axis of the plot to be nominal. The variadic arguments must be either strings or plotter.Valuers. Each valuer adds a box plot to the plot at the X location corresponding to the number of box plots added before it. If a plotter.Valuer is immediately preceeded by a string then the string value is used to label the tick mark for the box plot's X location.

            If an error occurs then none of the plotters are added to the plot, and the error is returned.

            func AddErrorBars

            func AddErrorBars(plt *plot.Plot, vs ...interface{}) error

              AddErrorBars adds XErrorBars and YErrorBars to a plot. The variadic arguments must be of type plotter.XYer, and must be either a plotter.XErrorer, plotter.YErrorer, or both. Each errorer is added to the plot the color from the Colors function corresponding to its position in the argument list.

              If an error occurs then none of the plotters are added to the plot, and the error is returned.

              func AddLinePoints

              func AddLinePoints(plt *plot.Plot, vs ...interface{}) error

                AddLinePoints adds Line and Scatter plotters to a plot. The variadic arguments must be either strings or plotter.XYers. Each plotter.XYer is added to the plot using the next color, dashes, and glyph shape via the Color, Dashes, and Shape functions. If a plotter.XYer is immediately preceeded by a string then a legend entry is added to the plot using the string as the name.

                If an error occurs then none of the plotters are added to the plot, and the error is returned.

                func AddLines

                func AddLines(plt *plot.Plot, vs ...interface{}) error

                  AddLines adds Line plotters to a plot. The variadic arguments must be a string or one of a plotting type, plotter.XYers or *plotter.Function. Each plotting type is added to the plot using the next color and dashes shape via the Color and Dashes functions. If a plotting type is immediately preceeded by a string then a legend entry is added to the plot using the string as the name.

                  If an error occurs then none of the plotters are added to the plot, and the error is returned.

                  func AddScatters

                  func AddScatters(plt *plot.Plot, vs ...interface{}) error

                    AddScatters adds Scatter plotters to a plot. The variadic arguments must be either strings or plotter.XYers. Each plotter.XYer is added to the plot using the next color, and glyph shape via the Color and Shape functions. If a plotter.XYer is immediately preceeded by a string then a legend entry is added to the plot using the string as the name.

                    If an error occurs then none of the plotters are added to the plot, and the error is returned.

                    func AddStackedAreaPlots

                    func AddStackedAreaPlots(plt *plot.Plot, xs plotter.Valuer, vs ...interface{}) error

                      AddStackedAreaPlots adds stacked area plot plotters to a plot. The variadic arguments must be either strings or plotter.Valuers. Each valuer adds a stacked area plot to the plot below the stacked area plots added before it. If a plotter.Valuer is immediately preceeded by a string then the string value is used to label the legend. Plots should be added in order of tallest to shortest, because they will be drawn in the order they are added (i.e. later plots will be painted over earlier plots).

                      If an error occurs then none of the plotters are added to the plot, and the error is returned.

                      func AddXErrorBars

                      func AddXErrorBars(plt *plot.Plot, es ...interface {
                      	plotter.XYer
                      	plotter.XErrorer
                      }) error

                        AddXErrorBars adds XErrorBars to a plot. The variadic arguments must be of type plotter.XYer, and plotter.XErrorer. Each errorer is added to the plot the color from the Colors function corresponding to its position in the argument list.

                        If an error occurs then none of the plotters are added to the plot, and the error is returned.

                        func AddYErrorBars

                        func AddYErrorBars(plt *plot.Plot, es ...interface {
                        	plotter.XYer
                        	plotter.YErrorer
                        }) error

                          AddYErrorBars adds YErrorBars to a plot. The variadic arguments must be of type plotter.XYer, and plotter.YErrorer. Each errorer is added to the plot the color from the Colors function corresponding to its position in the argument list.

                          If an error occurs then none of the plotters are added to the plot, and the error is returned.

                          func Color

                          func Color(i int) color.Color

                            Color returns the ith default color, wrapping if i is less than zero or greater than the max number of colors in the DefaultColors slice.

                            func Dashes

                            func Dashes(i int) []vg.Length

                              Dashes returns the ith default dash pattern, wrapping if i is less than zero or greater than the max number of dash patters in the DefaultDashes slice.

                              func MeanAndConf95

                              func MeanAndConf95(vls []float64) (mean, lowerr, higherr float64)

                                MeanAndConf95 returns the mean and the magnitude of the 95% confidence interval on the mean as low and high error values.

                                MeanAndConf95 may be used as the f argument to NewErrorPoints.

                                func MedianAndMinMax

                                func MedianAndMinMax(vls []float64) (med, lowerr, higherr float64)

                                  MedianAndMinMax returns the median value and error on the median given by the minimum and maximum data values.

                                  MedianAndMinMax may be used as the f argument to NewErrorPoints.

                                  func Shape

                                  func Shape(i int) draw.GlyphDrawer

                                    Shape returns the ith default glyph shape, wrapping if i is less than zero or greater than the max number of GlyphDrawers in the DefaultGlyphShapes slice.

                                    Types

                                    type ErrorPoints

                                    type ErrorPoints struct {
                                    	plotter.XYs
                                    	plotter.XErrors
                                    	plotter.YErrors
                                    }

                                      ErrorPoints holds a set of x, y pairs along with their X and Y errors.

                                      Example
                                      Output:
                                      
                                      

                                      func NewErrorPoints

                                      func NewErrorPoints(f func([]float64) (c, l, h float64), pts ...plotter.XYer) (*ErrorPoints, error)

                                        NewErrorPoints returns a new ErrorPoints where each point in the ErrorPoints is given by evaluating the center function on the Xs and Ys for the corresponding set of XY values in the pts parameter. The XError and YError are computed likewise, using the err function.

                                        This function can be useful for summarizing sets of scatter points using a single point and error bars for each element of the scatter.