ggDiamondLayer

Basic ggplot2 diamond plot layer construction functions

These functions are used by diamondPlot to construct a diamond plot. It's normally not necessary to call this function directly: instead, use meansDiamondPlot, meanSDtoDiamondPlot, and factorLoadingDiamondCIplot.

Keywords
hplot
Usage
ggDiamondLayer(data, ciCols = 1:3, colorCol = NULL, generateColors = NULL, fullColorRange = NULL, color = "black", otherAxisCol = 1:nrow(data), autoSize = NULL, fixedSize = 0.15, ...) diamondCoordinates(values, otherAxisValue = 1, direction = "horizontal", autoSize = NULL, fixedSize = 0.15)
Arguments
data
A dataframe (or matrix) containing lower bounds, centers (e.g. means), and upper bounds of intervals (e.g. confidence intervals).
ciCols
The columns in the dataframe with the lower bounds, centers (e.g. means), and upper bounds (in that order).
colorCol
The column in the dataframe containing the colors for each diamond, or a vector with colors (with as many elements as the dataframe has rows).
generateColors
A vector with colors to use to generate a gradient. These colors must be valid arguments to colorRamp (and therefore, to col2rgb).
fullColorRange
When specifying a gradient using generateColors, it is usually desirable to specify the minimum and maximum possible value corresponding to the outer anchors of that gradient. For example, when plotting numbers from 0 to 100 using a gradient from 'red' through 'orange' to 'green', none of the means may actually be 0 or 100; the lowest mean may be, for example, 50. If no fullColorRange is specified, the diamond representing that lowest mean of 50 wil be red, not orange. When specifying the fullColorRange, the lowest and highest 'colors' in generateColors are anchored to the minimum and maximum values of fullColorRange.
color
When no colors are automatically generated, all diamonds will have this color.
otherAxisCol
A vector of values, or the index of the column in the dataframe, that specifies the values for the Y axis of the diamonds. This should normally just be a vector of consecutive integers.
autoSize
Whether to make the height of each diamond conditional upon its length (the width of the confidence interval).
fixedSize
If not using relative heights, fixedSize determines the height to use.
...
Any additional arguments are passed to geom_polygon. This can be used to set, for example, the alpha value of the diamonds.
values
A vector of 2 or more values that are used to construct the diamond coordinates. If three values are provided, the middle one becomes the diamond's center. If two, four, or more values are provided, the median becomes the diamond's center.
otherAxisValue
The value on the other axis to use to compute the coordinates; this will be the Y axis value of the points of the diamond (if direction is 'horizontal') or the X axis value (if direction is 'vertical').
direction
Whether the diamonds should be constructed horizontally or vertically.
Value

ggDiamondLayer returns a ggplot geom_polygon object, which can then be used in ggplot plots (as diamondPlot does).diamondCoordinates returns a set of four coordinates that together specify a diamond.

See Also

meansDiamondPlot, meanSDtoDiamondPlot, factorLoadingDiamondCIplot, diamondPlot

Aliases
  • ggDiamondLayer
  • diamondCoordinates
Examples
## Not run: 
# ### (Don't run this example as a test, because we
# ###  need the ggplot function which isn't part of
# ###  this package.)
# 
# ### The coordinates for a simple diamond
# diamondCoordinates(values = c(1,2,3));
# 
# ### Plot this diamond
# ggplot() + ggDiamondLayer(data.frame(1,2,3));
# ## End(Not run)
Documentation reproduced from package userfriendlyscience, version 0.5-2, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.