Learn R Programming

zenplots (version 0.0-1)

plots_graphics: Graphics-Based Plotting Functions

Description

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

Usage

rug_1d_graphics(zargs,
                loc = 0.5, length = 0.5, width = 1, col = par("fg"),
                add = FALSE, plot... = NULL, ...)
points_1d_graphics(zargs,
                   loc = 0.5, cex = 0.4,
                   add = FALSE, plot... = NULL, ...)
jitter_1d_graphics(zargs,
                   loc = 0.5, offset = 0.25, cex = 0.4,
                   add = FALSE, plot... = NULL, ...)
hist_1d_graphics(zargs,
                 breaks = NULL, length.out = 21, col = NULL,
                 plot... = NULL, ...)
density_1d_graphics(zargs,
                    density... = NULL, offset = 0.08,
                    add = FALSE, plot... = NULL, ...)
boxplot_1d_graphics(zargs,
                    cex = 0.4, range = NULL, axes = FALSE,
                    add = FALSE, ...)
arrow_1d_graphics(zargs,
                  loc = c(0.5, 0.5), angle = 60, length = 0.6,
                  add = FALSE, plot... = NULL, ...)
rect_1d_graphics(zargs,
                 loc = c(0.5, 0.5), width = 1, height = 1,
                 add = FALSE, plot... = NULL, ...)
lines_1d_graphics(zargs,
                  loc = c(0.5, 0.5), length = 1,
                  add = FALSE, plot... = NULL, ...)
label_1d_graphics(zargs,
                  loc = c(0.5, 0.5), label = NULL, box = FALSE,
                  add = FALSE, plot... = NULL, ...)
layout_1d_graphics(zargs, ...)

group_2d_graphics(zargs, glabs, loc = c(0.5, 0.5), add = FALSE, plot... = NULL, ...) points_2d_graphics(zargs, cex = 0.4, box = FALSE, add = FALSE, group... = NULL, plot... = NULL, ...) density_2d_graphics(zargs, ngrids = 25, drawlabels = FALSE, axes = FALSE, box = FALSE, add = FALSE, group... = NULL, ...) axes_2d_graphics(zargs, length = 0.1, eps = 0.04, code = 2, xpd = NA, add = FALSE, group... = NULL, plot... = NULL, ...) arrow_2d_graphics(zargs, loc = c(0.5, 0.5), angle = 60, length = 0.2, add = FALSE, group... = NULL, plot... = NULL, ...) rect_2d_graphics(zargs, loc = c(0.5, 0.5), width = 1, height = 1, add = FALSE, group... = NULL, plot... = NULL, ...) label_2d_graphics(zargs, loc = c(0.98, 0.05), label = NULL, adj = 1:0, box = FALSE, add = FALSE, group... = NULL, plot... = NULL, ...) layout_2d_graphics(zargs, ...)

Arguments

zargs

argument list as passed from zenplot().

width

width of the rugs/rectangle.

height

height of the rugs/rectangle.

col

color (of the rugs) or vector of colors (for the bars and bar components; see barplot()).

add

logical indicating whether the current plot should be added to (or on top of) the previous one.

axes

A logical indicating whether axes should be drawn.

cex

character expansion factor.

offset

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

range

argument range of the underlying boxplot() (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).

loc

x-location or (x,y)-location (for 1d plots when viewed in the direction of the path; for 2d plots when viewed in normal viewing direction) of the center of the respective geometric shape or plot.

angle

angle between the two edges of the arrow head.

length

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

label

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

box

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

glabs

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

ngrids

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

drawlabels

logical indicating whether the contours should be labeled.

eps

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

code

integer code determining the kind of arrows to be drawn; see arrows.

xpd

logical or NA, determining the region with respect to which clipping takes place; see par().

adj

x (and optionally y) adjustment of the label.

density...

list() of additional arguments passed to the underlying density().

group...

list() of additional arguments passed to group_2d_graphics().

plot...

list() of additional arguments passed to the underlying plot().

additional arguments passed to the underlying graphics functions.

Value

(Mostly) invisible().

Details

These functions based on the R package graphics 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).

Overlaying of different graphics functions might not always turn out nicely (e.g. arrows over a boxplot; the latter creates problems concerning the spacing). For such tasks, it is recommended to work with grid via pkg = "grid" in zenplot().

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_graphics
points_1d_graphics
jitter_1d_graphics
density_1d_graphics
boxplot_1d_graphics
hist_1d_graphics
arrow_1d_graphics
rect_1d_graphics
lines_1d_graphics
label_1d_graphics
layout_1d_graphics

## Implementation of 2d functions (for plot2d of zenplot())
group_2d_graphics
points_2d_graphics
density_2d_graphics
axes_2d_graphics
arrow_2d_graphics
rect_2d_graphics
label_2d_graphics
layout_2d_graphics
# }

Run the code above in your browser using DataLab