% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/util_plotfunctions.R
\name{flexiplot}
\alias{flexiplot}
\title{Plot numeric or character values}
\usage{
flexiplot(
  x,
  y,
  type = NULL,
  lty = c(1, 2, 4, 3, 6, 5),
  lwd = 2,
  pch = c(1, 2, 0, 5, 6, 3),
  col = palette(),
  xlab = NULL,
  ylab = NULL,
  xlim = NULL,
  ylim = NULL,
  add = FALSE,
  xdomain = NULL,
  ydomain = NULL,
  alpha.f = 1,
  xjitter = NULL,
  yjitter = NULL,
  grid = TRUE,
  cex.main = 1,
  ...
)
}
\arguments{
\item{x}{Numeric or character: vector of x-coordinates. If missing, a numeric vector \code{1:...} is created having as many values as the rows of \code{y}.}

\item{y}{Numeric or character: vector of y coordinates. If missing, a numeric vector \code{1:...} is created having as many values as the rows of \code{x}.}

\item{type, lty, lwd, pch, col, xlab, ylab, add, cex.main}{see analogous arguments in \code{\link[graphics:matplot]{graphics::matplot()}}.}

\item{xlim, ylim}{\code{NULL} (default) or a vector of two values. In the latter case, if any of the two values is not finite (including \code{NA} or \code{NULL}), then the \code{min} or \code{max} \code{x}- or \code{y}-coordinates of the plotted points are used.}

\item{xdomain, ydomain}{Character or numeric or \code{NULL} (default): vector of possible values of the variables represented in the \code{x}- and \code{y}-axes, in case the \code{x} or \code{y} argument is a character vector. The ordering of the values is respected. If \code{NULL}, then \code{unique(x)} or \code{unique(y)} is used.}

\item{alpha.f}{Numeric, default 1: opacity of the colours, \code{0} being completely invisible and \code{1} completely opaque.}

\item{xjitter, yjitter}{Logical or \code{NULL} (default): add \code{\link[base:jitter]{base::jitter()}} to \code{x}- or \code{y}-values? Useful when plotting discrete variates. If \code{NULL}, jitter is added if the values are of character (or factor) class.}

\item{grid}{Logical: whether to plot a light grid. Default \code{TRUE}.}

\item{...}{Other parameters to be passed to \code{\link[graphics:matplot]{graphics::matplot()}}.}
}
\value{
\code{NULL}, \link[base:invisible]{invisibly}; produces a plot, see \code{\link[graphics:matplot]{graphics::matplot()}}.
}
\description{
Plot function that modifies and expands the \strong{graphics} package's \code{\link[graphics:matplot]{graphics::matplot()}} function in several ways.
}
\details{
This function is essentially a wrapper around \code{\link[graphics:matplot]{graphics::matplot()}}, augmenting the latter with some additional features useful for plotting data and results handled by \strong{Prova}. Some of the additional features provided by \code{flexiplot} are the following:
\itemize{
\item Either or both \code{x} and \code{y} arguments can be of class \code{\link[base:character]{base::character}}. In this case, axes labels corresponding to the unique values are used (see arguments \code{xdomain} and \code{ydomain}). This makes it easier to plot nominal and ordinal variates.
\item A jitter can also be added to the generated points, via the \code{xjitter} and \code{yjitter} switches. This makes it easier to generate scatter plots of nominal and ordinal variates.
\item It is possible to specify only a lower or upper limit in the \code{xlim} and \code{ylim} arguments, letting the other limit to be found automatically. This can be useful in plotting probabilities, in cases where we want to specify the lower, \code{0} limit, but want the upper limit to simply be the the maximum probability.
\item Transparency of lines or markers can be specified through argument \code{alpha.f}.
\item The plotting style is different, and default argument \code{type = 'l'} (line plot) rather than \code{type = 'p'} (point plot).
}

See the package's vignettes for more examples.
}
\examples{
## Scatter plot of the 'island' vs 'species' nominal variates of the penguins dataset;
## note how jitter is automatically added:
flexiplot(x = penguins[, 'species'], y = penguins[, 'island'])


## Scatter plot of the 'bill_len' vs 'species' variates of the penguins dataset:
flexiplot(x = penguins[, 'species'], y = penguins[, 'bill_len'])

## We can add jitter to separate the nominal values:
flexiplot(x = penguins[, 'species'], y = penguins[, 'bill_len'],
  xjitter = TRUE)


## Scatter plot of the 'bill_len' vs 'body_mass' variates;
## in this case we must specify the scatter-plot option `type = 'p'`:
flexiplot(x = penguins[, 'body_mass'], y = penguins[, 'bill_len'],
  type = 'p')

## Calculate the values of a normal distribution in a restricted range
x <- seq(from = -2, to = 2, length.out = 127)
y <- dnorm(x, mean = 0, sd = 1)

## plot the distribution, with 0 as the lower plot range:
flexiplot(x = x, y = y, ylim = c(0, NA))

}
\seealso{
\code{\link[=Pr]{Pr()}} to calculate posterior probabilities and quantiles.

\code{\link[=plot.probability]{plot.probability()}} to directly plot posterior probabilities and quantiles contained in a probability object.

\code{\link[=plotquantiles]{plotquantiles()}} to plot quantile ranges.
}
