Geometries

Geometries

Geometries are responsible for actually doing the drawing. A geometry takes as input one or more aesthetics, and use data bound to these aesthetics to draw things. For instance, the Geom.point geometry draws points using the x and y aesthetics, while the Geom.line geometry draws lines with those same two aesthetics.

Core geometries:

Derived geometries build on core geometries by automatically applying a default statistic:

Geom.abline[(; color=nothing, size=nothing, style=nothing)]

For each corresponding pair of elements in the intercept and slope aesthetics, draw the lines y = slope * x + intercept across the plot canvas. If unspecified, intercept defaults to [0] and slope to [1].

This geometry currently does not support non-linear Scale transformations.

source
Gadfly.Geom.barType.
Geom.bar[(; position=:stack, orientation=:vertical)]

Draw bars of height y centered at positions x, or from xmin to xmax. If orientation is :horizontal switch x for y. Optionally categorically groups bars using the color aesthetic. If position is :stack they will be placed on top of each other; if it is :dodge they will be placed side by side.

source
Geom.beeswarm[; (orientation=:vertical, padding=0.1mm)]

Plot the x and y aesthetics, the former being categorical and the latter continuous, by shifting the x position of each point to ensure that there is at least padding gap between neighbors. If orientation is :horizontal, switch x for y. Points can optionally be colored using the color aesthetic.

source
Geom.boxplot[(; method=:tukey, suppress_outliers=false)]

Draw box plots of the middle, lower_hinge, upper_hinge, lower_fence, upper_fence, and outliers aesthetics. The categorical x aesthetic is optional. If suppress_outliers is true, don't draw points indicating outliers.

Alternatively, if the y aesthetic is specified instead, the middle, hinges, fences, and outliers aesthetics will be computed using Stat.boxplot.

source
Geom.errorbar

Draw vertical error bars if the x, ymin, and ymax aesthetics are specified and/or horizontal error bars for y, xmin, and xmax. Optionally color them with color.

See also Geom.xerrorbar and Geom.yerrorbar.

source
Geom.hexbin[(; xbincount=200, ybincount=200)]

Bin the x and y aesthetics into tiled hexagons and color by count. xbincount and ybincount specify the number of bins. This behavior relies on the default use of Stat.hexbin.

Alternatively, draw hexagons of size xsize and ysize at positions x and y by passing Stat.identity to plot and manually binding the color aesthetic.

source
Geom.hline[(; color=nothing, size=nothing, style=nothing)]

Draw horizontal lines across the plot canvas at each position in the yintercept aesthetic.

source
Geom.label[(; position=:dynamic, hide_overlaps=true)]

Place the text strings in the label aesthetic at the x and y coordinates on the plot frame. Offset the text according to position, which can be :left, :right, :above, :below, :centered, or :dynamic. The latter tries a variety of positions for each label to minimize the number that overlap.

source
Geom.line[(; preserve_order=false, order=2)]

Draw a line connecting the x and y coordinates. Optionally plot multiple lines according to the group or color aesthetics. order controls whether the lines(s) are underneath or on top of other forms.

Set preserve_order to :true to not sort the points according to their position along the x axis, or use the equivalent Geom.path alias.

source
Geom.point

Draw scatter plots of the x and y aesthetics.

Optional Aesthetics

  • color: Categorical data will choose maximally distinguishable colors from the LCHab color space. Continuous data will map onto LCHab as well. Colors can also be specified explicitly for each data point with a vector of colors of length(x). A vector of length one specifies the color to use for all points. Default is Theme.default_color.

  • shape: Categorical data will cycle through Theme.point_shapes. Shapes can also be specified explicitly for each data point with a vector of shapes of length(x). A vector of length one specifies the shape to use for all points. Default is Theme.point_shapes[1].

  • size: Categorical data and vectors of Ints will interpolate between Theme.point_size_{min,max}. A continuous vector of AbstractFloats or Measures of length(x) specifies the size of each data point explicitly. A vector of length one specifies the size to use for all points. Default is Theme.point_size.

source
Geom.polygon[(; order=0, fill=false, preserve_order=false)]

Draw polygons with vertices specified by the x and y aesthetics. Optionally plot multiple polygons according to the group or color aesthetics. order controls whether the polygon(s) are underneath or on top of other forms. If fill is true, fill and stroke the polygons according to Theme.discrete_highlight_color, otherwise only stroke. If preserve_order is true, connect points in the order they are given, otherwise order the points around their centroid.

source
Geom.rectbin

Draw equal sizes rectangles centered at x and y positions. Optionally specify their color.

source
Geom.ribbon

Draw a ribbon at the positions in x bounded above and below by ymax and ymin, respectively. Optionally draw multiple ribbons by grouping with color.

source
Geom.segment[(; arrow=false, filled=false)]

Draw line segments from x, y to xend, yend. Optionally specify their color. If arrow is true a Scale object for both axes must be provided. If filled is true the arrows are drawn with a filled polygon, otherwise with a stroked line.

source
Geom.subplot_grid[(elements...)]

Draw multiple subplots in a grid organized by one or two categorial vectors.

Optional Aesthetics

  • xgroup, ygroup: Arrange subplots on the X and Y axes, respectively, by categorial data.

  • free_x_axis, free_y_axis: Whether the X and Y axis scales, respectively, can differ across the subplots. Defaults to false. If true, scales are set appropriately for individual subplots.

One or both of xgroup or ygroup must be bound. If only one, a single column or row of subplots is drawn, if both, a grid.

Arguments

Unlike most geometries, Geom.subplot_grid is typically passed one or more parameters. The constructor works for the most part like the layer function. Arbitrary plot elements may be passed, while aesthetic bindings are inherited from the parent plot.

source
Geom.violin[(; order=1)]

Draw y versus width, optionally grouping categorically by x and coloring with color. Alternatively, if width is not supplied, the data in y will be transformed to a density estimate using Stat.violin

source
Geom.vline[(; color=nothing, size=nothing, style=nothing)]

Draw vertical lines across the plot canvas at each position in the xintercept aesthetic.

source
Geom.xerrorbar

Draw horizontal error bars at y from xmin to xmax. Optionally color them with color.

source
Geom.yerrorbar

Draw vertical error bars at x from ymin to ymax. Optionally color them with color.

source
Geom.contours[(; levels=15, samples=150, preserve_order=true)]

Draw contour lines of the 2D function, matrix, or DataFrame in the z aesthetic. This geometry is equivalent to Geom.line with Stat.contour; see the latter for more information.

source
Geom.density[(; bandwidth=-Inf)]

Draw a line showing the density estimate of the x aesthetic. This geometry is equivalent to Geom.line with Stat.density; see the latter for more information.

source
Geom.density2d[(; bandwidth=(-Inf,-Inf), levels=15)]

Draw a set of contours showing the density estimate of the x and y aesthetics. This geometry is equivalent to Geom.line with Stat.density2d; see the latter for more information.

source
Geom.ellipse[(; distribution=MvNormal, levels=[0.95], nsegments=51, fill=false)]

Draw a confidence ellipse, using a parametric multivariate distribution, for a scatter of points specified by the x and y aesthetics. Optionally plot multiple ellipses according to the group or color aesthetics. This geometry is equivalent to Geom.polygon with Stat.ellipse; see the latter for more information.

source
Gadfly.Geom.hairMethod.
Geom.hair[(; intercept=0.0, orientation=:vertical)]

Draw lines from x, y to y=intercept if orientation is :vertical or x=intercept if :horizontal. Optionally specify their color. This geometry is equivalent to Geom.segment with Stat.hair.

source
Geom.histogram[(; position=:stack, bincount=nothing, minbincount=3, maxbincount=150,
                orientation=:vertical, density=false)]

Draw histograms from a series of observations in x or y optionally grouping by color. This geometry is equivalent to Geom.bar with Stat.histogram; see the latter for more information.

source
Geom.histogram2d[(; xbincount=nothing, xminbincount=3, xmaxbincount=150,
                    ybincount=nothing, yminbincount=3, ymaxbincount=150)]

Draw a heatmap of the x and y aesthetics by binning into rectangles and indicating density with color. This geometry is equivalent to Geom.rect with Stat.histogram2d; see the latter for more information.

source
Gadfly.Geom.pathMethod.
Geom.path

Draw lines between x and y points in the order they are listed. This geometry is equivalent to Geom.line with preserve_order=true.

source
Gadfly.Geom.rectMethod.
Geom.rect

Draw colored rectangles with the corners specified by the xmin, xmax, ymin and ymax aesthetics. Optionally specify their color.

source
Gadfly.Geom.smoothMethod.
Geom.smooth[(; method:loess, smoothing=0.75)]

Plot a smooth function estimated from the line described by x and y aesthetics. Optionally group by color and plot multiple independent smooth lines. This geometry is equivalent to Geom.line with Stat.smooth; see the latter for more information.

source
Gadfly.Geom.stepMethod.
Geom.step[(; direction=:hv)]

Connect points described by the x and y aesthetics using a stepwise function. Optionally group by color or group. This geometry is equivalent to Geom.line with Stat.step; see the latter for more information.

source
Gadfly.Geom.vectorMethod.
Geom.vector[(; filled=false)]

This geometry is equivalent to Geom.segment(arrow=true).

source
Geom.vectorfield[(; smoothness=1.0, scale=1.0, samples=20, filled=false)]

Draw a gradient vector field of the 2D function or a matrix in the z aesthetic. This geometry is equivalent to Geom.segment with Stat.vectorfield; see the latter for more information.

source