| minorLogTicks | R Documentation |
Calculate major and minor tick marks for log-scale axis
minorLogTicks(
side = NULL,
lims = NULL,
logBase = 2,
displayBase = 10,
logStep = 1,
minorWhich = c(2, 5),
asValues = TRUE,
offset = 0,
symmetricZero = (offset > 0),
col = "black",
col.ticks = col,
combine = FALSE,
logAxisType = c("normal", "flip", "pvalue"),
verbose = FALSE,
...
)
side |
|
lims |
|
logBase |
|
displayBase |
|
logStep |
|
minorWhich |
|
asValues |
|
offset |
|
symmetricZero |
|
col, col.ticks |
|
combine |
|
logAxisType |
|
verbose |
logical indicating whether to print verbose output. |
... |
additional parameters are ignored. |
This function is called by minorLogTicksAxis(), and
it may be better to use that function, or logFoldAxis()
or pvalueAxis() which has better preset options.
This function calculates log units for the axis of an existing base R plot. It calculates appropriate tick and label positions for:
major steps, which are typically in log steps; and
minor steps, which are typically a subset of steps at one lower log order.
For example, log 10 steps would be: c(1, 10, 100, 1000),
and minor steps would be c(2, 5, 20, 50, 200, 500, 2000, 5000).
This function is motivated to fill a few difficult cases:
Label axis ticks properly
when used together with offset. For example log2(1 + x)
uses offset=1. Other offsets can be used as relevant.
Create axis labels which indicate negative fold change
values, for example -2 in log2 fold change units would
be labeled with fold change -4, and not 0.0625.
Use symmetric tick marks around x=0 when applied to log fold changes.
Display actual P-values when plotting log10(Pvalue), which
is common for volcano plots.
list of axis tick positions, and corresponding labels,
for major and minor ticks. Note that labels may be numeric,
character, or expression. Specifically when expression
the graphics::axis() must be called once per label.
majorTicks: numeric position of each major tick mark
minorTicks: numeric position of each minor tick mark
allTicks: numeric position of each major tick mark
majorLabels: label to show for each tick mark
minorLabels: label to show for each tick mark
minorSet: the numeric steps requested for minor ticks
minorWhich: the numeric steps requested for minor labels
allLabelsDF: data.frame with all tick marks and labels, with
colname "use" indicating whether the label is displayed beside
each tick mark.
Other jam practical functions:
breakDensity(),
call_fn_ellipsis(),
checkLightMode(),
check_pkg_installed(),
colNum2excelName(),
color_dither(),
exp2signed(),
getAxisLabel(),
isFALSEV(),
isTRUEV(),
jargs(),
kable_coloring(),
lldf(),
log2signed(),
middle(),
newestFile(),
printDebug(),
reload_rmarkdown_cache(),
renameColumn(),
rmInfinite(),
rmNA(),
rmNAs(),
rmNULL(),
setPrompt()
## This example shows how to draw axis labels manually,
## but the function minorLogTicksAxis() is easier to use.
xlim <- c(0,4);
nullPlot(xlim=xlim, doMargins=FALSE);
mlt <- minorLogTicks(1,
logBase=10,
offset=1,
minTick=0);
maj <- subset(mlt$allLabelsDF, type %in% "major");
graphics::axis(1, las=2,
at=maj$tick, label=maj$text);
min <- subset(mlt$allLabelsDF, type %in% "minor");
graphics::axis(1, las=2, cex.axis=0.7,
at=min$tick, label=min$text,
col="blue");
graphics::text(x=log10(1+c(0,5,50,1000)), y=rep(1.7, 4),
label=c(0,5,50,1000), srt=90);
nullPlot(xlim=c(-4,10), doMargins=FALSE);
abline(v=0, lty=2)
graphics::axis(3, las=2);
minorLogTicksAxis(1, logBase=2, displayBase=10, symmetricZero=TRUE);
nullPlot(xlim=c(-4,10), doMargins=FALSE);
graphics::axis(3, las=2);
minorLogTicksAxis(1, logBase=2, displayBase=10, offset=1);
x2 <- stats::rnorm(1000) * 40;
d2 <- stats::density(log2(1+abs(x2)) * ifelse(x2<0, -1, 1));
lines(x=d2$x, y=normScale(d2$y)+1, col="green4");
nullPlot(xlim=c(0,10), doMargins=FALSE);
graphics::axis(3, las=2);
minorLogTicksAxis(1, logBase=2, displayBase=10, offset=1);
x1 <- c(0, 5, 15, 200);
graphics::text(y=rep(1.0, 4), x=log2(1+x1), label=x1, srt=90, adj=c(0,0.5));
graphics::points(y=rep(0.95, 4), x=log2(1+x1), pch=20, cex=2, col="blue");
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.