mdaplot: Plotting function for a single set of objects

View source: R/mdaplot.R

mdaplotR Documentation

Plotting function for a single set of objects

Description

mdaplot is used to make different kinds of plot for one set of data objects.

Usage

mdaplot(
  data = NULL,
  ps = NULL,
  type = "p",
  pch = 16,
  col = NULL,
  bg = par("bg"),
  bwd = 0.8,
  border = NA,
  lty = 1,
  lwd = 1,
  cex = 1,
  cgroup = NULL,
  xlim = NULL,
  ylim = NULL,
  colmap = "default",
  labels = NULL,
  main = NULL,
  xlab = NULL,
  ylab = NULL,
  show.labels = FALSE,
  show.colorbar = !is.null(cgroup),
  show.lines = FALSE,
  show.grid = TRUE,
  grid.lwd = 0.5,
  grid.col = "lightgray",
  show.axes = TRUE,
  xticks = NULL,
  yticks = NULL,
  xticklabels = NULL,
  yticklabels = NULL,
  xlas = 0,
  ylas = 0,
  lab.col = "darkgray",
  lab.cex = 0.65,
  show.excluded = FALSE,
  col.excluded = "#C0C0C0",
  nbins = 60,
  force.x.values = NA,
  opacity = 1,
  pch.colinv = FALSE,
  ...
)

Arguments

data

a vector, matrix or a data.frame with data values.

ps

'plotseries' object, if NULL will be created based on the provided data values

type

type of the plot ("p", "d", "l", "b", "h", "e").

pch

a character for markers (same as plot parameter).

col

a color for markers or lines (same as plot parameter).

bg

background color for scatter plots wich 'pch=21:25'.

bwd

a width of a bar as a percent of a maximum space available for each bar.

border

color for border of bars (if barplot is used)

lty

line type

lwd

line width

cex

scale factor for the marker

cgroup

a vector with values to use for make color groups.

xlim

limits for the x axis (if NULL, will be calculated automatically).

ylim

limits for the y axis (if NULL, will be calculated automatically).

colmap

a colormap to use for coloring the plot items.

labels

a vector with text labels for data points or one of the following: "names", "indices", "values".

main

an overall title for the plot (same as plot parameter).

xlab

a title for the x axis (same as plot parameter).

ylab

a title for the y axis (same as plot parameter).

show.labels

logical, show or not labels for the data objects.

show.colorbar

logical, show or not colorbar legend if color grouping is on.

show.lines

vector with two coordinates (x, y) to show horizontal and vertical line cross the point.

show.grid

logical, show or not a grid for the plot.

grid.lwd

line thinckness (width) for the grid.

grid.col

line color for the grid.

show.axes

logical, make a normal plot or show only elements (markers, lines, bars) without axes.

xticks

values for x ticks.

yticks

values for y ticks.

xticklabels

labels for x ticks.

yticklabels

labels for y ticks.

xlas

orientation of xticklabels.

ylas

orientation of yticklabels.

lab.col

color for data point labels.

lab.cex

size for data point labels.

show.excluded

logical, show or hide rows marked as excluded (attribute 'exclrows').

col.excluded

color for the excluded objects (rows).

nbins

if scatter density plot is shown, number of segments to split the plot area into. (see also ?smoothScatter)

force.x.values

vector with corrected x-values for a bar plot (do not specify this manually).

opacity

opacity for plot colors (value between 0 and 1).

pch.colinv

allows to swap values for 'col' and 'bg' for scatter plots with 'pch' valyes from 21 to 25.

...

other plotting arguments.

Details

Most of the parameters are similar to what are used with standard plot function. The differences are described below.

The function makes a plot of one set of objects. It can be a set of points (scatter plot), bars, lines, scatter-lines, errorbars og an image. The data is organized as a data frame, matrix or vector. For scatter and only first two columns will be used, for bar plot only values from the first row. It is recommended to use mda.subset method if plot should be made only for a subset of the data, especially if you have any excluded rows or columns or other special attributed, described in the Bookdown tutorial.

If data is a data frame and contains one or more factors, they will be converted to a dummy variables (using function mda.df2mat) and appears at the end (last columns) if line or bar plot is selected.

The function allows to colorize lines and points according to values of a parameter cgroup. The parameter must be a vector with the same elements as number of objects (rows) in the data. The values are divided into up to eight intervals and for each interval a particular color from a selected color scheme is assigned. Parameter show.colorbar allows to turn off and on a color bar legend for this option.

The used color scheme is defined by the colmap parameter. The default scheme is based on color brewer (colorbrewer2.org) diverging scheme with eight colors. There is also a gray scheme (colmap = "gray") and user can define its own just by specifing the needed sequence of colors (e.g. colmap = c("red", "yellow", "green"), two colors is minimum). The scheme will then be generated automatically as a gradient among the colors.

Besides that the function allows to change tick values and corresponding tick labels for x and y axis, see Bookdown tutorial for more details.

Author(s)

Sergey Kucheryavskiy (svkucheryavski@gmail.com)

See Also

mdaplotg - to make plots for several sets of data objects (groups of objects).

Examples

# See all examples in the tutorial.


mdatools documentation built on Aug. 13, 2023, 1:06 a.m.