prepLegend: Function for arranging plotting layout to accomodate a legend...

Description Usage Arguments Value Author(s) Examples

View source: R/legendFunctions.R

Description

Function for arranging plotting layout to accomodate a legend panel

Usage

1
2
3
prepLegend(layout = c(1, 1), type = if (is.matrix(layout)) "layout" else
  "mfrow", side = "right", proportion = 0.15, heights = NULL,
  widths = NULL)

Arguments

layout

layout vector or matrix

type

type of layout; either "mfrow" or "layout"

side

side of the plot to place legend on; one of "top", "bottom", "left" or "right"

proportion

proportion of plotting window to allocate to legend

heights

height vector for original layout (before the legend panel is appended)

widths

width vector for original layout (before the legend panel is appended)

Value

none; layout is passed to current device

Author(s)

Jason Waddell

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
layout <- c(2,3);
side <- "left"
proportion <- 0.2

prepLegend(layout = layout, side = side, proportion = proportion)
for(i in 1:(layout[1]*layout[2]))
	plot(1:7, 1:7, col = 1:7, pch = 19, cex = 2.2, xaxt = "n",
			yaxt = "n", ann = FALSE)
addLegend(legend = paste("Group", 1:7), font = 2,
		pch = 19, pt.cex = 2, text.col = 1:7, col = 1:7,
		y.intersp = 1.5, cex = 1.5)


layout = rbind(c(1, 2, 3), c(0, 4, 3), c(0, 4, 5))
side = "right"
proportion = 0.15

prepLegend(layout = layout, side = side, proportion = proportion)
for(i in 1:max(layout))
	plot(1:7, 1:7, col = 1:7, pch = 19, cex = 2.2, xaxt = "n",
			yaxt = "n", xlab = "", ylab = "", main = paste("Plot", i))
addLegend(legend = paste("Group", 1:7), font = 2,
		pch = 19, pt.cex = 2, text.col = 1:7, col = 1:7,
		y.intersp = 1.5, cex = 1.5)

Example output

Loading required package: oaColors

oaPlots documentation built on May 2, 2019, 6:46 a.m.

Related to prepLegend in oaPlots...