Documentation
¶
Overview ¶
Package geom provides basic geometric objects to display data in a plot.
The overall concept is loosely based in ggplot2's geoms. Each geom has some required aesthetics, typically an (x,y) coordinate and may provide the ability to optionally map other aestetics like line or fill color or size.
The required aestethics are a field like XY in the various geoms while the optional aestehtics are mapped through optional (Discrete)Aesthetics functions which provide a (discrete) value for a data point.
The different geoms have singular names like Rectangle or Point even if they may draw several rectangles or points to match the naming in ggplot2.
Index ¶
- func CanonicRectangle(r vg.Rectangle) vg.Rectangle
- func CopyAesthetics(dst, src interface{}, index func(int) int)
- func UpdateAestheticsRanges(dr *facet.DataRanges, n int, alpha Aesthetic, color Aesthetic, fill Aesthetic, ...)
- type Aesthetic
- type Bar
- type BarGroups
- func (bg *BarGroups) MaxGroupSize() int
- func (bg *BarGroups) MinDelta() float64
- func (bg *BarGroups) Record(x float64, i int)
- func (bg *BarGroups) Width(x float64, i int) (center float64, halfwidth float64)
- func (bg *BarGroups) XRange() (xmin float64, xmax float64)
- func (bg *BarGroups) Xs() []float64
- type BoxStyle
- type Boxplot
- type DiscreteAesthetic
- type HLine
- type Line
- type Path
- type Point
- type Rectangle
- type Segment
- type Step
- type Text
- type VLine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicRectangle ¶
CanonicRectangle returns the canonical form of r, i.e. its Min points having smaller coordinates than its Max point.
func CopyAesthetics ¶
CopyAesthetics copies the non-nil aesthetics from src to dst. The destination must be a pointer to a struct, the source may be a struct or a pointer to one. The index function can be used to reindex the aestetics functions between src and dst.
func UpdateAestheticsRanges ¶
func UpdateAestheticsRanges(dr *facet.DataRanges, n int, alpha Aesthetic, color Aesthetic, fill Aesthetic, shape DiscreteAesthetic, size Aesthetic, stroke DiscreteAesthetic)
UpdateAestheticsRanges is a helper to update the data ranges dr based on the non-nil aesthetics functions evaluated for all n data points.
Types ¶
type Bar ¶
type Bar struct {
XY plotter.XYer
Alpha Aesthetic
Color Aesthetic
Fill Aesthetic
Size Aesthetic
Stroke DiscreteAesthetic
Position string // "stack" (default), "dogde" or "fill"
GGap float64 // Gap between groups as fraction of sample distance.
BGap float64 // Gap inside a group as fraction of sample distance.
Default BoxStyle
}
Bar draws rectangles standing/hanging from y=0.
func (Bar) DataRange ¶
func (b Bar) DataRange() facet.DataRanges
type BarGroups ¶
type BarGroups struct {
Group map[float64][]int
Position string // "dodge" or something else
Ggap float64 // between groups
Dgap float64 // between bars inside a group if dodged
Same bool // Same width for all bars?
// contains filtered or unexported fields
}
func NewBarGroups ¶
NewBarGroups creates a BarGroups for dodged bar positioning with sensible gaps between bars.
func (*BarGroups) MaxGroupSize ¶
MaxGroupSize determines the maximum number of values recorded per x-values.
type BoxStyle ¶
BoxStyle combines a line style (for the border with a fill color for the interior of a geom. TODO: add the rest like size, symbol too?
type Boxplot ¶
type Boxplot struct {
Boxplot data.Boxplotter
Alpha Aesthetic
Color Aesthetic
Fill Aesthetic
Shape DiscreteAesthetic
Size Aesthetic
Stroke DiscreteAesthetic
Position string
Default BoxStyle
DefaultPoint draw.GlyphStyle
GGap, BGap float64
}
Boxplot draws rectangles. The coordinates are the outside coordinates, i.e. if the border is drawn for the rectangle then this border is drawn inside the rectangle given by the coordinates.
func (Boxplot) DataRange ¶
func (b Boxplot) DataRange() facet.DataRanges
type DiscreteAesthetic ¶
DiscreteAestetic is a function mapping a certain data point to a discrete aesthetic like Shape or Stroke.
type HLine ¶
type HLine struct {
Y plotter.Valuer
Alpha Aesthetic
Color Aesthetic
Size Aesthetic
Stroke DiscreteAesthetic
Default draw.LineStyle
}
HLine draws horizontal reference (or rule) lines at the given Y values.
func (HLine) DataRange ¶
func (h HLine) DataRange() facet.DataRanges
type Line ¶
type Line struct {
XY plotter.XYer
Alpha Aesthetic
Color Aesthetic
Size Aesthetic
Stroke DiscreteAesthetic
Default draw.LineStyle
}
Line connects the given points in order of the x values by straight line segments. The aestetics map the individual line segments based on their first point.
(To draw them in data order see Path.)
func (Line) DataRange ¶
func (l Line) DataRange() facet.DataRanges
type Path ¶
type Path struct {
XY plotter.XYer
Alpha Aesthetic
Color Aesthetic
Size Aesthetic
Stroke DiscreteAesthetic
Default draw.LineStyle
}
Path connects the given points in data order through straight line segments. The aestetics map the individual line segments based on their first point.
(To draw them in order of x values see Line.)
func (Path) DataRange ¶
func (p Path) DataRange() facet.DataRanges
type Point ¶
type Point struct {
XY plotter.XYer
Alpha Aesthetic
Color Aesthetic
Shape DiscreteAesthetic
Size Aesthetic
Default draw.GlyphStyle
}
Point draws points / symbols.
func (Point) DataRange ¶
func (p Point) DataRange() facet.DataRanges
type Rectangle ¶
type Rectangle struct {
XYUV data.XYUVer
Alpha Aesthetic
Color Aesthetic
Fill Aesthetic
Size Aesthetic
Stroke DiscreteAesthetic
Default BoxStyle
}
Rectangle draws rectangles. The coordinates are the outside coordinates, i.e. if the border is drawn for the rectangle then this border is drawn inside the rectangle given by the coordinates.
func (Rectangle) DataRange ¶
func (r Rectangle) DataRange() facet.DataRanges
type Segment ¶
type Segment struct {
XYUV data.XYUVer
Alpha Aesthetic
Color Aesthetic
Size Aesthetic
Stroke DiscreteAesthetic
Default draw.LineStyle
}
Segment draws line segments between two points (X,Y) and (U,V).
func (Segment) DataRange ¶
func (s Segment) DataRange() facet.DataRanges
type Step ¶
type Step struct {
XY plotter.XYer
Alpha Aesthetic
Color Aesthetic
Size Aesthetic
Stroke DiscreteAesthetic
// Vertical changes the step to "vertical then horizontal".
Vertical bool
Default draw.LineStyle
}
Step produces a stairstep plot of the given data.
func (Step) DataRange ¶
func (s Step) DataRange() facet.DataRanges
type Text ¶
type Text struct {
XYText data.XYTexter
Alpha Aesthetic
Color Aesthetic
Size Aesthetic
Default draw.TextStyle
}
Text draws points / symbols.
func (Text) DataRange ¶
func (t Text) DataRange() facet.DataRanges