Produce smooth scatter plot, a helper function called by
plotSmoothScatter()
.
smoothScatterJam(
x,
y = NULL,
nbin = 256,
bandwidth,
colramp = colorRampPalette(c("white", "lightblue", "blue", "orange", "orangered2")),
nrpoints = 100,
pch = ".",
cex = 1,
col = "black",
transformation = function(x) x^0.25,
postPlotHook = box,
xlab = NULL,
ylab = NULL,
xlim,
ylim,
add = FALSE,
xaxs = par("xaxs"),
yaxs = par("yaxs"),
xaxt = par("xaxt"),
yaxt = par("yaxt"),
useRaster = NULL,
...
)
numeric
vector, or data matrix with two or more columns.
numeric
vector, or if data is supplied via x as a matrix, y
is NULL.
integer
number of bins to use when converting the kernel
density result (which uses bandwidthN above) into a usable image.
For example, nbin=123 is the default used by
graphics::smoothScatter()
, however the
plotSmoothScatter()
function default is higher (256).
numeric
vector used to define the y- and x-axis
bandwidths, respectively, passed to KernSmooth::bkde2D()
,
which calculates the underlying 2-dimensional kernel density.
The plotSmoothScatter()
function was motivated by never wanting
to define this number directly, instead auto-calculation suitable
values.
function
that takes one numeric
argument and returns
that integer number of colors, by default 256.
integer
number of outlier datapoints to display,
as defined by graphics::smoothScatter()
, however the default here
is nrpoints=0
to avoid additional clutter in the output,
and because the default argument bandwidthN
usually indicates all
individual points.
point shape used when nrpoints>0
.
numeric
point size expansion factor used when nrpoints>0
.
character
R color used when nrpoints>0
.
function
which converts point density to a number,
typically related to square root or cube root transformation.
is NULL
for no post-plot hook, or a function
which
is called after producing the image plot. By default it is simply used
to draw a box around the image, but could be used to layer additional
information atop the image plot, for example contours, labels, etc.
character
x-axis label
character
y-axis label
numeric
x-axis range for the plot
numeric
y-axis range for the plot
logical
whether to add to an existing active R plot, or create
a new plot window.
character
value compatible with par("xaxs")
, mainly useful
for suppressing the x-axis, in order to produce a custom x-axis
range, most useful to restrict the axis range expansion done by R
by default.
character
value compatible with par("yaxs")
, mainly useful
for suppressing the y-axis, in order to produce a custom y-axis
range, most useful to restrict the axis range expansion done by R
by default.
character
value compatible with par("xaxt")
, mainly useful
for suppressing the x-axis, in order to produce a custom x-axis
by other mechanisms, e.g. log-scaled x-axis tick marks.
character
value compatible with par("yaxt")
, mainly useful
for suppressing the y-axis, in order to produce a custom y-axis
by other mechanisms, e.g. log-scaled y-axis tick marks.
NULL
or logical
indicating whether to invoke
graphics::rasterImage()
to produce a raster image.
If NULL, it determines whether to produce a raster image within the
imageDefault()
function, which checks the options
using getOption("preferRaster", FALSE)
to determine among
other things, whether the user prefers raster images, and if the
dev.capabilities()
supports raster.
additional arguments are passed to imageDefault()
and
optionally to plotPlotHook()
when supplied.
For general purposes, use plotSmoothScatter()
as a replacement
for graphics::smoothScatter()
, which produces better default
settings for pixel size and density bandwidth.
This function is only necessary in order to override the
graphics::smoothScatter()
function which calls
graphics::image.default()
.
Instead, this function calls imageDefault()
which is required
in order to utilize custom raster image scaling, particularly important
when the x- and y-axis ranges are not similar, e.g. where the x-axis spans
10 units, but the y-axis spans 10,000 units.
Other jam plot functions:
adjustAxisLabelMargins()
,
coordPresets()
,
decideMfrow()
,
drawLabels()
,
getPlotAspect()
,
groupedAxis()
,
imageByColors()
,
imageDefault()
,
minorLogTicksAxis()
,
nullPlot()
,
plotPolygonDensity()
,
plotRidges()
,
plotSmoothScatter()
,
shadowText_options()
,
shadowText()
,
showColors()
,
sqrtAxis()
,
usrBox()