plotSmoothScatter | R Documentation |
Produce scatter plot using point density instead of displaying individual data points.
plotSmoothScatter(
x,
y = NULL,
bwpi = 50,
binpi = 50,
bandwidthN = NULL,
nbin = NULL,
expand = c(0.04, 0.04),
transFactor = 0.25,
transformation = function(x) x^transFactor,
xlim = NULL,
ylim = NULL,
xlab = NULL,
ylab = NULL,
nrpoints = 0,
colramp = c("white", "lightblue", "blue", "orange", "orangered2"),
col = "black",
doTest = FALSE,
fillBackground = TRUE,
naAction = c("remove", "floor0", "floor1"),
xaxt = "s",
yaxt = "s",
add = FALSE,
asp = NULL,
applyRangeCeiling = TRUE,
useRaster = TRUE,
verbose = FALSE,
...
)
x |
numeric vector, or data matrix with two or more columns. |
y |
numeric vector, or if data is supplied via x as a matrix, y is NULL. |
bwpi |
|
binpi |
|
bandwidthN |
|
nbin |
|
expand |
|
transFactor |
|
transformation |
|
xlim |
|
ylim |
|
xlab , ylab |
|
nrpoints |
|
colramp |
any input recognized by
|
col |
|
doTest |
|
fillBackground |
|
naAction |
The latter two options are useful when the desired plot should indicate the presence of an NA value in either x or y, while also indicating the the corresponding non-NA value in the opposing axis. The driving use was plotting gene fold changes from two experiments, where the two experiments may not have measured the same genes. |
xaxt |
|
yaxt |
|
add |
|
asp |
|
applyRangeCeiling |
|
useRaster |
|
verbose |
|
... |
additional arguments are passed to called functions,
including |
This function intends to make several potentially customizable
features of graphics::smoothScatter()
plots much easier
to customize. For example bandwidthN allows defining the number of
bandwidth steps used by the kernel density function, and importantly
bases the number of steps on the visible plot window, and not the range
of data, which can differ substantially. The nbin
argument is related,
but is used to define the level of detail used in the image function,
which when plotting numerous smaller panels, can be useful to reduce
unnecessary visual details.
This function also by default produces a raster image plot
with useRaster=TRUE
, which adjusts the x- and y-bandwidth to
produce visually round density even when the x- and y-ranges
are very different.
Comments:
asp=1
will define an aspect ratio 1, meaning the x-axis and y-axis
units will be the same physical size in the output device.
When this is true, and fillBackground=TRUE
the xlim
and ylim
values follow logic for plot.default()
and plot.window()
such that
each axis will include at least the xlim
and ylim
ranges, with
additional range included in order to maintain the plot aspect ratio.
When asp
, and any of xlim
or ylim
, are defined, the data will
be "cropped" to respective xlim
and ylim
values as relevant,
after which the plot is drawn with the appropriate plot aspect ratio.
When applyRangeCeiling=TRUE
, points outside the fixed xlim
and ylim
range are fixed to the edge of the range, after which the plot is drawn
with the requested plot aspect ratio. It is recommended not to define
xlim
and ylim
when also defining asp
.
When add=TRUE
the xlim
and ylim
values are already defined
by the plot device. It is recommended not to define xlim
and ylim
when add=TRUE
.
Other jam plot functions:
adjustAxisLabelMargins()
,
coordPresets()
,
decideMfrow()
,
drawLabels()
,
getPlotAspect()
,
groupedAxis()
,
imageByColors()
,
imageDefault()
,
minorLogTicksAxis()
,
nullPlot()
,
plotPolygonDensity()
,
plotRidges()
,
shadowText_options()
,
shadowText()
,
showColors()
,
smoothScatterJam()
,
sqrtAxis()
,
usrBox()
# doTest=TRUE invisibly returns the test data
x <- plotSmoothScatter(doTest=TRUE);
# so it can be plotted again with different settings
colnames(x) <- c("column_1", "column_2")
plotSmoothScatter(x, colramp="inferno");
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.