cranvas (version 0.8.5)

qdensity: Draw a univariate density plot

Description

Draw a univariate density plot, with a rug plot underneath.

Usage

qdensity(x, data, binwidth = NULL, main = "", xlim = NULL, ylim = NULL, xlab = NULL, ylab = NULL)

Arguments

x
variable name which designates variable displayed on the horizontal axis
data
a mutaframe created by qdata
main
the main title
xlim
a numeric vector of length 2 (like c(x0, x1)) for x-axis limits; it will be calculated from the data limits if not specified (NULL). Note when x0 > x1, the axis direction will be reversed (i.e. from larger values to small values)
ylim
y-axis limits; similar to xlim
xlab
x-axis title
ylab
y-axis title
binwidth
the bin width (range(x) / bins by default)

Details

Common interactions are documented in common_key_press. Specific interactions include: Arrow Up/Down in-/de-creases size of points; Arrow Left/Right de-/in-creases binwidth for density; Key Z toggle zoom on/off (default is off); mouse click & drag will specify a zoom window.

Note there are two short tickmarks in the plot denoting the binwidth.

See Also

Other plots: qbar; qboxplot; qhist, qspine; qmval; qparallel; qtime

Examples

Run this code
library(cranvas)

### (1) ames housing data
qames <- qdata(ameshousing)

qdensity(saleprice, data = qames)

### (2) tennis data
qtennis <- qdata(tennis)

qdensity(first.serve.pct, data = qtennis)

qdensity(second.serve.pts, data = qtennis)
qdensity(serve.speed, data = qtennis)

record_selector(name, data = qtennis)

### (3) pollen data
if (require("animation")) {
    data(pollen, package = "animation")
    qpollen <- qdata(pollen)
    print(qdensity(RIDGE, data = qpollen))
}

### (4) flea (with colors)
data(flea, package = "tourr")
qflea <- qdata(flea, color = species)

qdensity(tars1, data = qflea)

qdensity(tars2, data = qflea)
qdensity(aede1, data = qflea)
qdensity(aede3, data = qflea)

cranvas_off()

Run the code above in your browser using DataCamp Workspace