Type: | Package |
Title: | Advanced Text-Based Plots |
Version: | 1.0.2 |
Date: | 2015-09-22 |
Author: | Hien D. Nguyen |
Maintainer: | Hien D. Nguyen <h.nguyen7@uq.edu.au> |
Description: | Provides functions to produce advanced ascii graphics, directly to the terminal window. This package utilizes the txtplot() function from the 'txtplot' package, to produce text-based histograms, empirical cumulative distribution function plots, scatterplots with fitted and regression lines, quantile plots, density plots, image plots, and contour plots. |
License: | LGPL-3 |
Depends: | txtplot |
NeedsCompilation: | no |
Packaged: | 2015-09-23 13:35:46 UTC; hiennguyen |
Repository: | CRAN |
Date/Publication: | 2015-09-24 01:24:01 |
nos.image text-based contour plot.
Description
Produces a text-based contour plot for the visualization of three-dimensional data that are stored in a matrix.
Usage
nos.contour(data, xmin = 1, xmax = dim(data)[1], ymin = 1,
ymax = dim(data)[2], xlab = NULL, ylab = NULL, ratio = 0.35,
width = round(options()$width * 0.8), height = round(ratio * width),
pch = 1:5)
Arguments
data |
A numeric matrix of data to be plotted. |
xmin |
A numeric value indicating the smallest x-axis value, which corresponds to the first row of data. |
xmax |
A numeric value indicating the greatest x-axis value, which corresponds to the last row of data. |
ymin |
A numeric value indicating the smallest y-axis value, which corresponds to the first column of data. |
ymax |
A numeric value indicating the greatest y-axis value, which corresponds to the last column of data. |
xlab |
Label of the x-axis of the plot. |
ylab |
Label of the y-axis of the plot. |
ratio |
Coefficient that controls the aspect ratio of the plot. |
width |
Width of the plot in points. |
height |
Height of the plot in points. |
pch |
A vector of single-character symbols. The length of the vector determines the number of contours to be plotted. From left to right, the symbols represent an increasing order of contour values. |
Note
Due to rounding to a relatively crude grid results can only be approximate. The equally spaced axis ticks, for example, may be non-equally spaced in the plot. Further, due to the crude grid also there might be several points per character. The function uses the same plotting symbol no matter how many points coincide on one character position. The contour values are equally spaced quantiles between the 5% and 95% level, and are produced using the quantile
function. The legend reports the value associated with each contour.
Author(s)
Hien D. Nguyen
See Also
quantile
, contour
, contourLines
, volcano
, and txtplot
.
Examples
## Produce the contour plot of the volcano dataset, using the default plotting symbols.
library(datasets)
nos.contour(volcano)
## Produce the contour plot of the volcano dataset, using the plotting symbols letters[1:3].
library(datasets)
nos.contour(volcano,pch=letters[1:3])
nos.density text-based plot of a kernel density function.
Description
Plots a text-based of a kernel density function, with the option of plotting the location of the data points along the x-axis.
Usage
nos.density(data, xlab = NULL, ratio = 0.25, bw = "nrd0",
kernel = "gaussian", locations = T, width = round(options()$width *
0.8), height = round(ratio * width), pch = c("o", "~"))
Arguments
data |
A numeric vector containing the values to be plotted. |
xlab |
Label of the x-axis of the plot. |
ratio |
Coefficient that controls the aspect ratio of the plot. |
bw |
A numerical value or character string to specify the bandwidth used for kernel density estimation. The default setting is |
kernel |
A character string to specify the type of smoothing kernel used. The default setting is |
locations |
If |
width |
Width of the plot in points. |
height |
Height of the plot in points. |
pch |
A two dimensional vector of single-character symbols. The first symbol is for data point, and the second symbol is for the density curve. |
Note
Due to rounding to a relatively crude grid results can only be approximate. The equally spaced axis ticks, for example, may be non-equally spaced in the plot. Further, due to the crude grid also there might be several points per character. The function uses the same plotting symbol no matter how many points coincide on one character position.
Author(s)
Hien D. Nguyen
See Also
density
, plot
, txtplot
, and txtdensity
.
Examples
## Plot a kernel density function of 10 random standard normal points with
## a Gaussian kernel and with the locations of the data plotted along the x-axis.
data <- rnorm(10)
nos.density(data)
## Plot a kernel density function of 100 random stanard normal points with
## a triangular kernel and without the locations of the data plotted along the x-axis.
data <- rnorm(100)
nos.density(data,kernel='triangular',location=FALSE)
nos.ecdf text-based plot of an empirical CDF.
Description
Plots a text-based empirical cumulative distribution function.
Usage
nos.ecdf(data, xlab = NULL, ratio = 0.25, width = round(options()$width *
0.8), height = round(ratio * width), pch = "o")
Arguments
data |
A numeric vector containing the values to be plotted. |
xlab |
Label of the x-axis of the plot. |
ratio |
Coefficient that controls the aspect ratio of the plot. |
width |
Width of the plot in points. |
height |
Height of the plot in points. |
pch |
A single-character plot symbol. |
Note
Due to rounding to a relatively crude grid results can only be approximate. The equally spaced axis ticks, for example, may be non-equally spaced in the plot. Further, due to the crude grid also there might be several points per character. The function uses the same plotting symbol no matter how many points coincide on one character position.
Author(s)
Hien D. Nguyen
See Also
Examples
## Plot the empirical CDF of 10 random standard normal points with 'o' shaped points.
data <- rnorm(10)
nos.ecdf(data)
## Plot the empirical CDF of 100 random stanard normal points with '*' shaped points
data <- rnorm(100)
nos.ecdf(data,pch='*')
nos.hist text-based plot of a histogram.
Description
Plots a text-based of a histogram, with the option to plot densities or frequencies.
Usage
nos.hist(data, breaks = "Sturges", freq = T, xlab = NULL, ratio = 0.25,
width = round(options()$width * 0.8), height = round(ratio * width),
pch = "o")
Arguments
data |
A numeric vector containing the values to be plotted. |
breaks |
Either a numerical value or a character string to specify the number of breaks to used. The default setting is |
freq |
If |
xlab |
Label of the x-axis of the plot. |
ratio |
Coefficient that controls the aspect ratio of the plot. |
width |
Width of the plot in points. |
height |
Height of the plot in points. |
pch |
A single-character plot symbol. |
Note
Due to rounding to a relatively crude grid results can only be approximate. The equally spaced axis ticks, for example, may be non-equally spaced in the plot. Further, due to the crude grid also there might be several points per character. The function uses the same plotting symbol no matter how many points coincide on one character position. Histogram columns are plotted at the midpoint of each bin.
Author(s)
Hien D. Nguyen
See Also
Examples
## Plot a histogram for the frequencies of 100 random standard normal points
## using 'Sturges' breaks and plot symbol 'o'.
data <- rnorm(100)
nos.hist(data)
## Plot a histogram for the densities of 1000 random chi-squared(3) points
## using 'FD' breaks and plot symbol '#'.
data <- rchisq(1000,3)
nos.hist(data,breaks='FD',freq=FALSE,pch='#')
nos.image text-based image plot.
Description
Produces a text-based image plot for the visualization of three-dimensional data that are stored in a matrix.
Usage
nos.image(data, xmin = 1, xmax = dim(data)[1], ymin = 1,
ymax = dim(data)[2], xlab = NULL, ylab = NULL, ratio = 0.35,
width = round(options()$width * 0.8), height = round(ratio * width),
pch = c(".", "o", "x", "X", "#"))
Arguments
data |
A numeric matrix of data to be plotted. |
xmin |
A numeric value indicating the smallest x-axis value, which corresponds to the first row of data. |
xmax |
A numeric value indicating the greatest x-axis value, which corresponds to the last row of data. |
ymin |
A numeric value indicating the smallest y-axis value, which corresponds to the first column of data. |
ymax |
A numeric value indicating the greatest y-axis value, which corresponds to the last column of data. |
xlab |
Label of the x-axis of the plot. |
ylab |
Label of the y-axis of the plot. |
ratio |
Coefficient that controls the aspect ratio of the plot. |
width |
Width of the plot in points. |
height |
Height of the plot in points. |
pch |
A vector of single-character symbols. The length of the vector determines the number of bins that the data is partitioned into. From left to right, the symbols represent an increasing order of binned. |
Note
Due to rounding to a relatively crude grid results can only be approximate. The equally spaced axis ticks, for example, may be non-equally spaced in the plot. Further, due to the crude grid also there might be several points per character. The function uses the same plotting symbol no matter how many points coincide on one character position. The bins are equally spaced between the minimum and the maximum value of the data matrix, and are produced using the hist
function. The legend reports the smallest and largest value of each bin associated with each plot symbol.
Author(s)
Hien D. Nguyen
See Also
hist
, image
, volcano
, and txtplot
.
Examples
## Produce the image plot of the volcano dataset, using the default plotting symbols.
library(datasets)
nos.image(volcano)
## Produce the image plot of the volcano dataset, using the plotting symbols 1:9.
library(datasets)
nos.image(volcano,pch=1:9)
nos.legend Generates a text-based legend for plots.
Description
Generates a text-based legend that relates plot characters to functional values or outcomes.
Usage
nos.legend(nams, legend = 1:length(nams), width)
Arguments
nams |
A vector that specifies what each plot symbol represents. |
legend |
A character vector of the plot symbols. |
width |
A numeric value that specifies the number of characters to be printed before a line-break. |
Author(s)
Hien D. Nguyen
See Also
Examples
## Generates a legend that relates the plot symbols c('a','b','c') to
## the functional values c(1,2,3) with line-breaks every 14 characters.
nos.legend(c(1,2,3),c('a','b','c'),14)
nos.qqnorm text-based normal quantile-quantile plots
Description
Produces a text-based normal quantile-quantile plot where the theoretical quantiles are plotted along the x-axis and the sample quantiles are plotted along the y-axis.
Usage
nos.qqnorm(data, line = T, ratio = 0.25, width = round(options()$width *
0.8), height = round(ratio * width), pch = c("o", "~"))
Arguments
data |
A numeric vector containing the values to be plotted. |
line |
If |
ratio |
Coefficient that controls the aspect ratio of the plot. |
width |
Width of the plot in points. |
height |
Height of the plot in points. |
pch |
A two dimensional vector of single-character symbols. The first symbol is for data point, and the second symbol is for the line of theoretical quantile equality. |
Note
Due to rounding to a relatively crude grid results can only be approximate. The equally spaced axis ticks, for example, may be non-equally spaced in the plot. Further, due to the crude grid also there might be several points per character. The function uses the same plotting symbol no matter how many points coincide on one character position.
Author(s)
Hien D. Nguyen
See Also
Examples
## Produce a normal quantile-quantile plot of 10 random standard normal points,
## without the line of theoretical quantile equality.
data <- rnorm(10)
nos.qqnorm(data,line=FALSE)
## Produce a normal quantile-quantile plot of 100 random chi-squared(3) points,
## with the line of theoretical quantile equality.
data <- rchisq(100,3)
nos.qqnorm(data)
nos.qqplot text-based generic quantile-quantile plots
Description
Produces a text-based quantile-quantile plot between two equal size samples, with the option of plotting a line of theoretical quantile equality.
Usage
nos.qqplot(x, y, xlab = NULL, ylab = NULL, line = T, ratio = 0.25,
width = round(options()$width * 0.8), height = round(ratio * width),
pch = c("o", "~"))
Arguments
x |
A numeric vector containing the values to be plotted along the x-axis. |
y |
A numeric vector containing the values to be plotted along the y-axis. |
xlab |
Label of the x-axis of the plot. |
ylab |
Label of the y-axis of the plot. |
line |
If |
ratio |
Coefficient that controls the aspect ratio of the plot. |
width |
Width of the plot in points. |
height |
Height of the plot in points. |
pch |
A two dimensional vector of single-character symbols. The first symbol is for data point, and the second symbol is for the line of theoretical quantile equality. |
Note
Due to rounding to a relatively crude grid results can only be approximate. The equally spaced axis ticks, for example, may be non-equally spaced in the plot. Further, due to the crude grid also there might be several points per character. The function uses the same plotting symbol no matter how many points coincide on one character position.
Author(s)
Hien D. Nguyen
See Also
qqplot
, qqline
, ppoints
, and txtplot
.
Examples
## Produce a quantile-quantile plot between two samples of 10 random standard normal points,
## without the line of theoretical quantile equality.
x <- rnorm(10)
y <- rnorm(10)
nos.qqplot(x,y,line=FALSE)
## Produce a quantile-quantile plot of 100 random chi-squared(3) points against the
## true theoretical distribution, with the line of theoretical quantile equality.
y <- rchisq(100,3)
x <- qchisq(ppoints(100),3)
nos.qqplot(x,y,xlab='Theoretical Qs',ylab='Sample Qs')
nos.xyplot text-based scatter plot.
Description
Plots a text-based scatter plot, with the option of having a regression line, or a linear interpolation of the points.
Usage
nos.xyplot(x = 1:length(y), y, xlab = NULL, ylab = NULL, ratio = 0.25,
width = round(options()$width * 0.8), height = round(ratio * width),
pch = c("o", "~"), type = "p")
Arguments
x |
A numeric vector containing the x-values to be plotted. |
y |
A numeric vector containing the y-values to be plotted. |
xlab |
Label of the x-axis of the plot. |
ylab |
Label of the y-axis of the plot. |
ratio |
Coefficient that controls the aspect ratio of the plot. |
width |
Width of the plot in points. |
height |
Height of the plot in points. |
pch |
A two dimensional vector of single-character symbols. The first symbol is for the x and y coordinate points, and the second symbol is for the interpolation or regression line. |
type |
One of the values in the set |
Note
Due to rounding to a relatively crude grid results can only be approximate. The equally spaced axis ticks, for example, may be non-equally spaced in the plot. Further, due to the crude grid also there might be several points per character. The function uses the same plotting symbol no matter how many points coincide on one character position.
Author(s)
Hien D. Nguyen
See Also
Examples
## Plot 10 correlated points
x <- 10*runif(10)
y <- x + rnorm(10)
nos.xyplot(x,y,type='p',xlab='x',ylab='y')
## Plot 10 correlated points with a regression line
x <- 10*runif(10)
y <- x + rnorm(10)
nos.xyplot(x,y,type='pr',xlab='x',ylab='y')
## Plot 10 correlated points with a linear interpolation
x <- 10*runif(10)
y <- x + rnorm(10)
nos.xyplot(x,y,type='lp',xlab='x',ylab='y')