Title: | Advanced Text-Based Plots |
---|---|
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. |
Authors: | Hien D. Nguyen |
Maintainer: | Hien D. Nguyen <[email protected]> |
License: | LGPL-3 |
Version: | 1.0.2 |
Built: | 2024-12-11 06:43:55 UTC |
Source: | CRAN |
Produces a text-based contour plot for the visualization of three-dimensional data that are stored in a matrix.
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)
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)
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. |
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.
Hien D. Nguyen
quantile
, contour
, contourLines
, volcano
, and txtplot
.
## 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])
## 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])
Plots a text-based of a kernel density function, with the option of plotting the location of the data points along the x-axis.
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", "~"))
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", "~"))
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. |
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.
Hien D. Nguyen
density
, plot
, txtplot
, and txtdensity
.
## 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)
## 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)
Plots a text-based empirical cumulative distribution function.
nos.ecdf(data, xlab = NULL, ratio = 0.25, width = round(options()$width * 0.8), height = round(ratio * width), pch = "o")
nos.ecdf(data, xlab = NULL, ratio = 0.25, width = round(options()$width * 0.8), height = round(ratio * width), pch = "o")
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. |
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.
Hien D. Nguyen
## 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='*')
## 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='*')
Plots a text-based of a histogram, with the option to plot densities or frequencies.
nos.hist(data, breaks = "Sturges", freq = T, xlab = NULL, ratio = 0.25, width = round(options()$width * 0.8), height = round(ratio * width), pch = "o")
nos.hist(data, breaks = "Sturges", freq = T, xlab = NULL, ratio = 0.25, width = round(options()$width * 0.8), height = round(ratio * width), pch = "o")
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. |
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.
Hien D. Nguyen
## 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='#')
## 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='#')
Produces a text-based image plot for the visualization of three-dimensional data that are stored in a matrix.
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", "#"))
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", "#"))
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. |
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.
Hien D. Nguyen
hist
, image
, volcano
, and txtplot
.
## 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)
## 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)
Generates a text-based legend that relates plot characters to functional values or outcomes.
nos.legend(nams, legend = 1:length(nams), width)
nos.legend(nams, legend = 1:length(nams), width)
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. |
Hien D. Nguyen
## 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)
## 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)
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.
nos.qqnorm(data, line = T, ratio = 0.25, width = round(options()$width * 0.8), height = round(ratio * width), pch = c("o", "~"))
nos.qqnorm(data, line = T, ratio = 0.25, width = round(options()$width * 0.8), height = round(ratio * width), pch = c("o", "~"))
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. |
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.
Hien D. Nguyen
## 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)
## 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)
Produces a text-based quantile-quantile plot between two equal size samples, with the option of plotting a line of theoretical quantile equality.
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", "~"))
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", "~"))
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. |
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.
Hien D. Nguyen
qqplot
, qqline
, ppoints
, and txtplot
.
## 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')
## 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')
Plots a text-based scatter plot, with the option of having a regression line, or a linear interpolation of the points.
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")
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")
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 |
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.
Hien D. Nguyen
## 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')
## 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')