Description Usage Arguments Examples
A simple utility method for visualizing a list of data.
1 2 3 4 5 6 7 8 | batchPlot.list(data, xfun = function(x) x$x, yfun = function(x) x$y,
ffun = function(x) x$f, plotXY = TRUE, widthXY = 0.5,
plotXF = TRUE, widthXF = 1.5, names = NULL,
colors = colors.distinct(length(data)), xlab = "", ylab = "",
legend = NULL, x.min.lower = NA, x.min.upper = NA,
x.max.lower = NA, x.max.upper = NA, y.min.lower = NA,
y.min.upper = NA, y.max.lower = NA, y.max.upper = NA,
x.add = NULL, XYType = "p", XFType = "l", ...)
|
data |
the data object, could be a list of lists or anything |
xfun |
a function which receives an element from the |
yfun |
a function which receives an element from the |
ffun |
a function which receives an element from the |
plotXY |
should the |
widthXY |
the line width for points to be plotted (only considered if
|
plotXF |
should the |
widthXF |
the line width for lines to be plotted (only considered if
|
names |
the names of the lines to be printed in the legend, or
|
colors |
the colors to be used for the plot |
xlab |
the label for the x-axis |
ylab |
the label for the y-axis |
legend |
a list of additional parameters to be passed to
|
x.min.lower |
a lower bound for the automatically computed |
x.min.upper |
an upper bound for the automatically computed |
x.max.lower |
a lower bound for the automatically computed |
x.max.upper |
an upper bound for the automatically computed |
y.min.lower |
a lower bound for the automatically computed |
y.min.upper |
an upper bound for the automatically computed |
y.max.lower |
a lower bound for the automatically computed |
y.max.upper |
an upper bound for the automatically computed |
x.add |
some additional |
XYType |
the type in which the XY data should be plotted, by default
|
XFType |
the type in which the XF data should be plotted, by default
|
... |
Arguments passed on to |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | library(plotteR)
# set a random seed for replicability
set.seed(1367);
# make an example
make.example <- function(f) {
n <- as.integer(round(runif(n=1, min=10, max=200)));
x <- sort(runif(n=n, min=0, max=3)); # generate x data
y <- rnorm(n=n, mean=f(x), s=0.1); # noisy y
x <- rnorm(n=n, mean=x, s=0.1); # noisy x
return(list(x=x, y=y, f=f));
}
# the three base functions
f <- c(function(x) 1 - 0.2*x + 0.75*x*x - 0.3*x*x*x,
function(x) 0.1 * exp(3 - x),
function(x) 1.2 + 0.7*sin(2*x));
# create the three example data sets
examples <- lapply(X=f, FUN=make.example);
# plot the original data
batchPlot.list(examples,
names=c("f1", "f2", "f3"),
main="Original Data and Function Values for x",
legend=list(x="bottom", horiz=TRUE));
library(plotteR)
# set a random seed for replicability
set.seed(1367);
# make an example
make.example <- function(f) {
suppressWarnings({
repeat {
n <- as.integer(round(runif(n=1, min=10, max=20)));
x <- sort(runif(n=n, min=-5, max=5)); # generate x data
y <- rnorm(n=n, mean=f(x), s=0.1); # noisy y
x <- rnorm(n=n, mean=x, s=0.1); # noisy x
fi <- is.finite(x) & is.finite(y);
x <- x[fi];
if(length(x) > 4L) {
y <- y[fi];
return(list(x=x, y=y, f=f));
}
}
});
}
# the three base functions
f <- c(function(x) 1 - 0.2*x + 0.75*x*x - 0.3*x*x*x,
log, # this function becomes non-finite for x <= 0
asin); # non-finite for any x outside of [-1, 1]
# create the three example data sets
examples <- lapply(X=f, FUN=make.example);
old <- par(mfcol=c(2, 1));
# plot the original data, which only covers part of the x.axis
batchPlot.list(examples,
names=c("f1", "f2", "f3"),
main="Original Data and Function Values for x",
legend=list(x="left"),
y.min.lower = -3,
y.max.upper= 3);
abline(v=-1, col="gray");abline(v=0, col="gray");abline(v=1, col="gray");
# extending the function lines towards their smallest and largest finite
# points
batchPlot.list(examples,
names=c("f1", "f2", "f3"),
main="Functions Extented by Finite Point Search",
legend=list(x="left"),
y.min.lower = -3,
y.max.upper= 3,
x.add = TRUE);
abline(v=-1, col="gray");abline(v=0, col="gray");abline(v=1, col="gray");
par(old);
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.