R/phasePortraitBw.R
phasePortraitBw.Rd
phasePortraitBw
allows for creating two-color phase portraits of
complex functions based on a polar chessboard grid (cf.
Wegert (2012)
, p. 35). Compared to
the full phase portraits that can be made with phasePortrait
,
two-color portraits omit information. Especially in combination with full
phase portraits they can be, however, very helpful tools for interpretation.
Besides, two-color phase portraits have a special aesthetic appeal which is
worth exploring for itself. In its parameters and its mode of operation,
phasePortraitBw
is very similar to phasePortrait
.
phasePortraitBw( FUN, moreArgs = NULL, xlim, ylim, invertFlip = FALSE, res = 150, blockSizePx = 2250000, tempDir = NULL, nCores = max(1, parallel::detectCores() - 1), bwType = "ma", pi2Div = 18, logBase = exp(2 * pi/pi2Div), argOffset = 0, bwCols = c("black", "gray95", "gray"), asp = 1, deleteTempFiles = TRUE, noScreenDevice = FALSE, autoDereg = FALSE, verbose = TRUE, ... )
FUN | The function to be visualized. There are two possibilities to
provide it, a quoted character string, or a function object. The quoted
character string must contain an expression that can be interpreted by R as
a function of a complex number |
---|---|
moreArgs | A named list of other arguments to FUN. The names must match the names of the arguments in FUN's definition. |
xlim | The x limits (x1, x2) of the plot as a two-element numeric
vector. Follows exactly the same definition as in
|
ylim | The y limits of the plot (y1, y2) to be used in the same way as
|
invertFlip | If |
res | Desired resolution of the plot in dots per inch (dpi). Default is
150 dpi. All other things being equal, |
blockSizePx | Number of pixels and corresponding complex values to be processed at the same time (see Details). Default is 2250000. This value gave good performance on older systems as well as on a high-end gaming machine, but some tweaking for your individual system might even improve things. |
tempDir |
|
nCores | Number of processor cores to be used in the parallel computing
tasks. Defaults to the maximum number of cores available minus 1. Any
number between 1 (serial computation) and the maximum number of cores
available as indicated by |
bwType | One of the three options for plotting, "m", "a", and "ma", to
be provided as a character string. Defaults to "ma". This parameter has a
comparable role to the parameter |
pi2Div | Angle distance for the argument reference zones added for
|
logBase | Modulus ratio between the edges of the modulus zones in
|
argOffset | The (complex number) argument in radians counterclockwise, at which the argument (phase angle) reference zones are fixed, i.e. the lower angle of the first zone. Default is 0. |
bwCols | Color definition for the plot provided as a character vector of
length 3. Each element of the vector must be either a color name R
recognizes, or a hexadecimal color string like e.g. "#00FF11". The first
and the second color make the appearance of two-color phase portraits (see
|
asp | Aspect ratio y/x as defined in |
deleteTempFiles | If TRUE (default), all temporary files are deleted after the plot is completed. Set it on FALSE only, if you know exactly what you are doing - the temporary files can occupy large amounts of hard disk space (see details). |
noScreenDevice | Suppresses any graphical output if TRUE. This is only
intended for test purposes and makes probably only sense together with
|
autoDereg | if TRUE, automatically register sequential backend after the
plot is completed. Default is FALSE, because registering a parallel backend
can be time consuming. Thus, if you want to make several phase portraits in
succession, you should set |
verbose | if TRUE (default), |
... | All parameters accepted by the |
This function is intended to be used inside the framework of R base graphics.
It plots into the active open graphics device where it will display the phase
plot of a user defined function as a raster image. If no graphics device is
open when called, the function will plot into the default graphics device.
This principle allows to utilize the full functionality of R base graphics.
All graphics parameters (par
) can be freely set and the
function phasePortrait
accepts all parameters that can be passed to
the plot.default
function. This allows all kinds of plots -
from scientific representations with annotated axes and auxiliary lines,
notation, etc. to poster-like artistic pictures. The general mode of operation,
including the usage of parallel processing is exactly the same as with
phasePortrait
, see details section there.
Wegert E (2012). Visual Complex Functions. An Introduction with Phase Portraits. Springer, Basel Heidelberg New York Dordrecht London. ISBN 978-3-0348-0179-9.
# Map the complex plane on itself # x11(width = 8, height = 8) # Screen device commented out # due to CRAN test requirements. # Use it when trying this example phasePortraitBw("z", xlim = c(-2, 2), ylim = c(-2, 2), xlab = "real", ylab = "imaginary", verbose = FALSE, # Suppress progress messages nCores = 2) # Max. two cores allowed on CRAN # not a limit for your own use # Sinus with default colors and default bwType ("ma") # \donttest{ # x11(width = 8, height = 8) # Screen device commented out # due to CRAN test requirements. # Use it when trying this example phasePortraitBw("sin(z)", xlim = c(-pi, pi), ylim = c(-pi, pi), verbose = FALSE, nCores = 2) # Max. two cores allowed on CRAN # not a limit for your own use # } # Sinus with custom colors and bwType "a" # \donttest{ # x11(width = 8, height = 8) # Screen device commented out # due to CRAN test requirements. # Use it when trying this example phasePortraitBw("sin(z)", xlim = c(-pi, pi), ylim = c(-pi, pi), bwType = "a", bwCols = c("darkgreen", "green", "gray"), verbose = FALSE, nCores = 2) # Max. two cores allowed on CRAN # not a limit for your own use # } # Sinus with custom colors and bwType "m" # \donttest{ # x11(width = 8, height = 8) # Screen device commented out # due to CRAN test requirements. # Use it when trying this example phasePortraitBw("sin(z)", xlim = c(-pi, pi), ylim = c(-pi, pi), bwType = "m", bwCols = c("darkblue", "skyblue", "gray"), verbose = FALSE, nCores = 2) # Max. two cores allowed on CRAN # not a limit for your own use # } # Map the complex plane on itself, show all bwType options # \donttest{ # x11(width = 8, height = 8) # Screen device commented out # due to CRAN test requirements. # Use it when trying this example op <- par(mfrow = c(2, 2), mar = c(4.1, 4.1, 1.1, 1.1)) for(bwType in c("ma", "a", "m")) { phasePortraitBw("z", xlim = c(-2, 2), ylim = c(-2, 2), bwType = bwType, xlab = "real", ylab = "imaginary", verbose = FALSE, # Suppress progress messages nCores = 2) # Max. two cores allowed on CRAN # not a limit for your own use } # Add normal phase portrait for comparison phasePortrait("z", xlim = c(-2, 2), ylim = c(-2, 2), xlab = "real", ylab = "imaginary", verbose = FALSE, pi2Div = 18, # Use same angular division as default # in phasePortraitBw nCores = 2) par(op) # } # A rational function, show all bwType options # \donttest{ # x11(width = 8, height = 8) # Screen device commented out # due to CRAN test requirements. # Use it when trying this example funString <- "(z + 1.4i - 1.4)^2/(z^3 + 2)" op <- par(mfrow = c(2, 2), mar = c(4.1, 4.1, 1.1, 1.1)) for(bwType in c("ma", "a", "m")) { phasePortraitBw(funString, xlim = c(-2, 2), ylim = c(-2, 2), bwType = bwType, xlab = "real", ylab = "imaginary", verbose = FALSE, # Suppress progress messages nCores = 2) # Max. two cores allowed on CRAN # not a limit for your own use } # Add normal phase portrait for comparison phasePortrait(funString, xlim = c(-2, 2), ylim = c(-2, 2), xlab = "real", ylab = "imaginary", verbose = FALSE, pi2Div = 18, # Use same angular division as default # in phasePortraitBw nCores = 2) par(op) # }