ScatterPlot: Enhanced scatterplot with fitting lines

Description Usage Arguments Details Value Author(s) See Also Examples

Description

This function creates a scatterplot with fitting lines. Points and fitting lines can be also computed by groups.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ScatterPlot(x, y, groups = NULL, plot.type = NULL, objfct = FALSE, 
    which.objfct = c("Cor", "Pbias", "RMSE"), add = FALSE, density.levels = 50, 
    density.labels = FALSE, image.nbrks = 300, fits = c("spline"), 
    fit.quantile = NULL, fit.minnobs = 10, fit.groups = TRUE, 
    fit.global = TRUE, col.points = "black", col.image = NULL, 
    col.density = NULL, col.fit = col.points, col.global = NULL, 
    xlab = "", ylab = "", main = "", xlim = NULL, ylim = NULL, 
    lwd = 2, lty = 1, quantile.x = c(0.01, 0.99), quantile.y = c(0.01, 
        0.99), plot = TRUE, cex = NULL, pch = 21, alpha = NULL, 
    nrpoints = NULL, legend = TRUE, ...)

Arguments

x

vector of x values

y

vector of y values

groups

vector of grouping variables (optional), in case of NULL all points are treated as one group

plot.type

plot type: possible arguments are 'density' to plot density lines, 'points' to plot points, or 'image' to plot point counts as a raster image. In case of NULL, the optimal plot.type will be determined dependent on the number of values. It is also possible to combine plot types (e.g. c("image", "density")).

objfct

Compute objective functions and add a 1:1 line to the plot?

which.objfct

Which objective functions should be added to legend of the plot if objfct=TRUE?

add

add plot to existing plot?

density.levels

number of levels for density lines

density.labels

add labels to density lines?

image.nbrks

minimum number of breaks for the image

fits

Fitting methods that should be used. See MultiFit for details. If several methods area provided the mean of all methods is plotted.

fit.quantile

Compute fit to a certain quantile? If NULL, fits to the mean. Otherwise sa value between 0 and 1 can be specified to fit to a certain quantile.

fit.minnobs

minimum number of observations per group in order to calculate a fitting curve

fit.groups

Plot fit lines for groups?

fit.global

Plot global fit lines?

col.points

color for the points/groups

col.image

color range for image

col.density

color range for density lines

col.fit

colors for fitting lines

col.global

colors for global fittiing line

xlab

a title for the x axis

ylab

a title for the y axis

main

an overall title for the plot

xlim

range for the x axis

ylim

range for the y axis

lwd

line width

lty

line type

quantile.x

lower and upper quantile to exclude extreme x values from plotting and fit calculations

quantile.y

lower and upper quantile to exclude extreme y values from plotting and fit calculations

plot

should a scatterplot be plotted or calculate only fitting lines

cex

size of the points in the plot. If NULL point size will be calculated based on the number of points.

pch

point symbol

alpha

transparency of the points (0...255)

nrpoints

number of outlier points to be drawn on images

legend

dsiplay a legend?

...

further arguments to MultiFit or plot.default

Details

This function plots a scatterplot.

Value

The function returns a list with the computed fitting lines and objective functions per group.

Author(s)

Matthias Forkel <matthias.forkel@geo.tuwien.ac.at> [aut, cre]

See Also

ObjFct

Examples

 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
# create some data:
n <- 10000
x <- runif(n, 0, 100)
groups <- c(rep(1, 3000), rep(2, 3000), rep(3, 4000))
y <- (3 * x^(1/2) + rnorm(n, 0, x/20)) * groups

# standard plot: not very well distinguishable
plot(x, y)

# ScatterPlot 
result <- ScatterPlot(x, y)
result <- ScatterPlot(x, y, col.image=c("red", "grey", "blue"))

# ScatterPlot with coulored groups and fitting lines
result <- ScatterPlot(x, y, groups)

# different plot types 
result <- ScatterPlot(x, y, plot.type="points")
result <- ScatterPlot(x, y, plot.type="density")
result <- ScatterPlot(x, y, plot.type=c("image", "density"))
result <- ScatterPlot(x, y, groups, plot.type=c("image", "points"))

# plot and compute objective functions
result <- ScatterPlot(x, y, groups, objfct=TRUE)
result

# plot fits to upper 0.9 and lower 0.1 quantiles, mean fit from two methods
result <- ScatterPlot(x, y, groups, fits=c("poly3", "spline"), 
 fit.quantile=0.9, plot.type="image", fit.global=FALSE)
result <- ScatterPlot(x, y, groups, fits=c("poly3", "spline"), 
 fit.quantile=0.1, plot.type=NA, add=TRUE, fit.global=FALSE)

ModelDataComp documentation built on Nov. 22, 2020, 3 a.m.