Learn R Programming

zenplots (version 0.0-1)

plots_grid: Grid-Based Plotting Functions

Description

The 1d and 2d plotting functions based on the R package grid.

Usage

rug_1d_grid(zargs,
            loc = 0.5, length = 0.5, width = 1e-3, col = par("fg"),
            draw = FALSE, ...)
points_1d_grid(zargs,
               loc = 0.5, pch = 21, size = 0.02,
               draw = FALSE, ...)
jitter_1d_grid(zargs,
               loc = 0.5, offset = 0.25, pch = 21, size = 0.02,
               draw = FALSE, ...)
hist_1d_grid(zargs,
             breaks = NULL, length.out = 21, col = NULL, fill = NULL,
             draw = FALSE, ...)
density_1d_grid(zargs,
                density... = NULL, offset = 0.08,
                draw = FALSE, ...)
boxplot_1d_grid(zargs,
                pch = 21, size = 0.02,
                col = NULL, lwd = 2, bpwidth = 0.5, range = NULL,
                draw = FALSE, ...)
arrow_1d_grid(zargs,
              loc = c(0.5, 0.5), angle = 60, length = 0.6,
              draw = FALSE, ...)
rect_1d_grid(zargs,
             loc = c(0.5, 0.5), width = 1, height = 1,
             draw = FALSE, ...)
lines_1d_grid(zargs,
              loc = c(0.5, 0.5), length = 1, arrow = NULL,
              draw = FALSE, ...)
label_1d_grid(zargs,
              loc = c(0.5, 0.5), label = NULL, cex = 0.66,
              box = FALSE, box.width = 1, box.height = 1,
              draw = FALSE, ...)
layout_1d_grid(zargs, ...)

group_2d_grid(zargs, glabs, loc = c(0.5, 0.5), draw = FALSE, ...) points_2d_grid(zargs, type = c("p", "l", "o"), pch = NULL, size = 0.02, box = FALSE, box.width = 1, box.height = 1, group... = list(cex = 0.66), draw = FALSE, ...) density_2d_grid(zargs, ngrids = 25, ccol = NULL, clwd = 1, clty = 1, box = FALSE, box.width = 1, box.height = 1, group... = list(cex = 0.66), draw = FALSE, ...) axes_2d_grid(zargs, angle = 30, length = unit(0.05, "npc"), type = "open", eps = 0.02, group... = list(cex = 0.66), draw = FALSE, ...) arrow_2d_grid(zargs, loc = c(0.5, 0.5), angle = 60, length = 0.2, group... = list(cex = 0.66), draw = FALSE, ...) rect_2d_grid(zargs, loc = c(0.5, 0.5), width = 1, height = 1, group... = list(cex = 0.66), draw = FALSE, ...) label_2d_grid(zargs, loc = c(0.98, 0.05), label = NULL, cex = 0.66, just = c("right", "bottom"), rot = 0, box = FALSE, box.width = 1, box.height = 1, group... = list(cex = cex), draw = FALSE, ...) layout_2d_grid(zargs, ...)

Arguments

zargs

argument list as passed from zenplot().

width

width (passed on to the underlying grid functions).

height

height (passed on to the underlying grid functions).

just

justification (see rectGrob() and textGrob()).

col

for

rug_1d_grid:

color and fill color of the rectangels forming the rugs.

boxplot_1d_grid:

color of the box, whiskers and points.

hist_1d_grid:

color of the bins.

draw

logical indicating whether graphics output is produced.

pch

plot symbol.

size

plot symbol size as passed to pointsGrob().

offset

number in \([0, 0.5]\) determining how far away the plot stays from the plot margins (for creating space between the two).

lwd

line width.

bpwidth

width of the boxplot (in default.units).

range

determines how far the plot whiskers extend out of the box. If range = NULL, this will be automatically determined depending on the sample size.

breaks

break points for the histogram as passed to the underlying hist(). If NULL, the default is to use 20 equi-width bins covering the range of the data.

length.out

number of break points if is.null(breaks).

fill

fill color of the bins.

loc

(x,y)-location of the center of the arrow.

arrow

see linesGrob().

label

label to be used (with default being the column names of the data if NULL).

rot

rotation of the label in degrees.

box

logical indicating whether a box is drawn around the plot region.

box.width

width of the box (if drawn).

box.height

height of the box (if drawn).

cex

character expansion (aims for a useful default for grid but might not always be suitable -- for that one would need to know both the number of rows and columns in the plot layout and yet this would still be affected by the size of the plot window).

glabs

group labels being indexed by the plot variables; if NULL, they are determined with extract_2d() and the underlying burst().

group...

list of arguments passed to group_2d_grid() (or NULL)

ngrids

number of grid points in each dimension (a scalar or an integer vector of length two).

ccol, clwd, clty

colors (col), line widths (lwd) andline types (lty) of the contour lines. These can be single values or vectors (which are then recycled).

angle

angle between the two edges of the arrow head.

length

length of the arrow in [0,1] from tip to base.

type

axis type.

eps

distance by which the axes are moved away from the plot region.

density...

list() of arguments for the underlying density().

additional (graphical) parameters passed to gpar().

Value

(Mostly) the underlying grob via invisible().

Details

These functions based on the R package grid are provided as useful defaults for the arguments plot1d and plot2d of zenplot(), respectively. See zenplot() for how to use them, their source code for how to adjust them or how to write your own plot1d or plot2d. The main idea is that zenplot() passes on the zargs arguments to the plot1d or plot2d functions and the ellipsis argument is used to pass down all other (mostly graphical) parameters (to both plot1d or plot2d; via gpar()).

See Also

zenplot() for how to use these functions.

Examples

Run this code
# NOT RUN {
## Implementation of 1d functions (for plot1d of zenplot())
rug_1d_grid
points_1d_grid
jitter_1d_grid
density_1d_grid
boxplot_1d_grid
hist_1d_grid
arrow_1d_grid
rect_1d_grid
lines_1d_grid
label_1d_grid
layout_1d_grid

## Implementation of 2d functions (for plot2d of zenplot())
group_2d_grid
points_2d_grid
density_2d_grid
axes_2d_grid
arrow_2d_grid
rect_2d_grid
label_2d_grid
layout_2d_grid
# }

Run the code above in your browser using DataLab