designGGPlot: Plots labels on two-way grids of coloured cells using...

designGGPlotR Documentation

Plots labels on two-way grids of coloured cells using ggplot2 to represent an experimental design

Description

Plots the labels in a grid of cells specified by row.factors and column.factors. The cells can be coloured by the values of the column specified by column.name and can be divided into facets by specifying multiple row and or column factors.

Usage

designGGPlot(design, labels = NULL, label.size = NULL, 
             row.factors = "Rows", column.factors = "Columns", 
             scales.free = "free", facetstrips.switch = NULL, 
             facetstrips.placement = "inside", 
             cellfillcolour.column = NULL, colour.values = NULL, 
             cellalpha = 1, celllinetype = "solid", celllinesize = 0.5, 
             celllinecolour = "black", cellheight = 1, cellwidth = 1,
             reverse.x = FALSE, reverse.y = TRUE, x.axis.position = "top", 
             xlab, ylab, title, labeller = label_both, 
             title.size = 15, axis.text.size = 15, 
             blocksequence = FALSE, blockdefinition = NULL, 
             blocklinecolour = "blue", blocklinesize = 2, 
             printPlot = TRUE, ggplotFuncs = NULL, ...)

Arguments

design

A data.frame containing labels, column.factors, row.factors and, if specified, colour.column.

labels

A character giving the name of the column in data containing the labels to be plotted on the grid. If labels is NULL, no labels are added.

label.size

A numeric giving the size of the labels.

row.factors

A character giving the names of the factors (or numerics) in data that index the rows of the plot grid used to represent the design. If there is more than one name, then facet_grid is used to facet the plot in the y direction, based on all but the last name. The factor corresponding to the last name will index the rows in each facet.

column.factors

A character giving the names of the factors (or numerics) in data that index the columns of the plot grid used to represent the design. If there is more than one name, then facet_grid is used to facet the plot in the x direction, based on all but the last name. The factor corresponding to the last name will index the columns in each facet.

scales.free

When plots are facetted, a character specifying whether scales are shared across all facets (fixed), or vary across rows (free_x), columns (free_y), or both rows and columns (the default, free). The free_x, free_y and free options may not work when the plot grid is indexed using numerics.

facetstrips.switch

When plots are facetted, the strip text are displayed on the top and right of the plot by default. If facetstrips.switch is "x", the top strip text will be switched to the bottom. If "y", the right-hand side labels will be switched to the left. The argument can also be set to "both". The argument facetstrips.placement can be used to change the relationship between the strip text and the axis.text and the axis.title.

facetstrips.placement

A character nominating where the strip is to be placed with respect to axes text and titles, either "inside" both text and titles, "outside.text" or "outside.title". This argument is important only when axes and strips are on the same side of the plot. When this occurs, the default is to place them inside the axis text. Note: This argument must be specified only once in the constructon of the plot and after every other aspect of the plot has been finalized. In particular, if designBlocksGGPlot is to called after designGGPlot to add block boundaries, then facetstrips.placement should be specified in the call to designBlocksGGPlot, not in the call to designGGPlot.

reverse.x

A logical which, if true, causes the order of values on the x-axis to be reversed, the natural order being to increase from left to right.

reverse.y

A logical which, if true, causes the order of values on the y-axis to be reversed, the natural order being to increase from bottom to top.

x.axis.position

A character giving the position of the x-axis; can be top or bottom.

cellfillcolour.column

A character giving the name of the column in data that is to be used to vary the colour the used to fill a cell.

colour.values

A character giving the name or names of the colours to be used in filling the cell. If cellfillcolour.column is not NULL then the number of colours sepcified needs to match the number of unique values in the cellfillcolour.column.

cellalpha

A numeric specifying the degree of transparency to be used in cell fill. It is a ratio in which the denominator specifies the number of points (or lines) that must be overplotted to give a solid cover.

celllinetype

A numeric or character giving the type of line for the cell border. An integer or name: 0 = blank, 1 = solid, 2 = dashed, 3 = dotted, 4 = dotdash, 5 = longdash, 6 = twodash. For more information see vignette("ggplot2-specs").

celllinesize

A numeric specifying the size of the line in mm.

celllinecolour

A character giving the name of the colour to use for the cell outline.

cellheight

A numeric specifying the height of a cell.

cellwidth

A numeric specifying the width of of a cell.

xlab

Label for the x-axis. By default it is the last name in the column.factors.

ylab

Label for the y-axis. By default it is the last name in the row.factors.

title

Title for plot window. By default it is "Plot of labels".

labeller

A function for specifying the formatting of the strip labels of the facet grids used when there is more than one row.factors or column.factors. (See labellers for ggplot2.)

title.size

A numeric giving the size for all titles: xlab, ylab and title.

axis.text.size

A numeric giving the size for tick labels.

blocksequence

A logical that determines whether block numbers are repetitions or sequences of block numbers.

blockdefinition

A matrix of block sizes:

  • if there is only one row, then the first element is interpreted as the no. rows in each block and blocks with this number of rows are to be repeated across the rows of the design.

  • if there is more than one row, then each row of the matrix specifies a block, with the sequence of rows in the matrix specifying a corresponding sequence of blocks down the rows of the design.

Similarly, a single value for a column specifies a repetition of blocks of that size across the columns of the design, while several column values specifies a sequence of blocks across the columns of the size specified.

blocklinecolour

A character string specifying the colour of the block boundary.

See also the scale_colour_* functions or Colour specification under the par function.

blocklinesize

A numeric giving the width of the block boundary to be plotted.

printPlot

A logical indicating whether to print the plot produced.

ggplotFuncs

A list, each element of which contains the results of evaluating a ggplot function. It is created by calling the list function with a ggplot function call for each element. These functions are applied in creating the ggplot object.

...

Other arguments that are passed down to the geom_text call that plots the labels.

Value

An object of class "ggplot", which can be plotted using print.

Author(s)

Chris Brien

See Also

designBlocksGGPlot, fac.combine in package dae, designPlot.

Examples

#### Plot a randomized complete block design
Treatments <- factor(rep(1:6, times = 5))
RCBD.lay <- designRandomize(allocated = Treatments,
                            recipient = list(Blocks = 5, Units = 6),
                            nested.recipients = list(Units = "Blocks"),
                            seed = 74111)
designGGPlot(RCBD.lay, labels = "Treatments", label.size = 5, 
             row.factors = "Blocks", column.factors = "Units", 
             blockdefinition = cbind(1,5))
             
## Plot without labels
designGGPlot(RCBD.lay, cellfillcolour.column = "Treatments", 
             row.factors = "Blocks", column.factors = "Units", 
             colour.values = c("lightblue","lightcoral","lightgoldenrod",
                               "lightgreen","lightgrey", "lightpink"), 
             blockdefinition = cbind(1,6))

             
#### Plot a lattice square design
data(LatticeSquare_t49.des)
designGGPlot(LatticeSquare_t49.des, labels = "Lines", label.size = 5, 
             row.factors = c("Intervals", "Runs"), column.factors = "Times", 
             blockdefinition = cbind(7,7))

dae documentation built on Aug. 7, 2023, 5:08 p.m.