nos.xyplot: nos.xyplot text-based scatter plot.

Description Usage Arguments Note Author(s) See Also Examples

View source: R/NostalgiR.R

Description

Plots a text-based scatter plot, with the option of having a regression line, or a linear interpolation of the points.

Usage

1
2
3
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. NA and NaN are allowed, but are removed for the plot. Infinities will cause an error.

y

A numeric vector containing the y-values to be plotted. NA and NaN are allowed, but are removed for the plot. Infinities will cause an error.

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 c('l','p','r','lp','pr'). Type 'l' plots a linear interpolation, type 'p' plots the x and y coordinates as points, type 'r' plots a linear regression line, type 'lp' plots x and y coordinates along with a linear interpolation, and type 'pr' plots x and y coordinates along with a linear regression line.

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

plot and txtplot.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## 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')

Example output

Loading required package: txtplot
  10 +-+-----------+----------+----------+-----------+---------+
     |                                                    o o  |
     |                                       o             o   |
   8 +                                                         +
     |                                               o         |
   6 +                                     o                   +
     |                                                         |
y  4 +                    o                                    +
     |                                                         |
   2 +                                                         +
     |            o                                            |
     |                                                         |
   0 +  o         o                                            +
     +-+-----------+----------+----------+-----------+---------+
       0           2          4          6           8          
                                  x                             
     +----+------------+-------------+------------+------------+
     |                                                      o  |
  10 +                                                         +
     |                                                  ~~~~~  |
   8 +                                           ~~~~~~~~      +
     |                                     ~~~~o~~             |
   6 +                               ~~~~~~~      o            +
y    |             o          ~~~~~~~~                         |
   4 +                  ~~~~~~~  o                             +
     |        o   ~~~~~~~     o                                |
     |  o  ~~~~~~~~                                            |
   2 +  ~o~~                                                   +
     |  o                                                      |
   0 +----+------------+-------------+------------+------------+
          2            4             6            8             
                                  x                             
    +----------+-------------+-------------+-------------+-----+
    |                                               ~o~~~      |
  8 +                                             ~~     ~~~o  +
    |                                           ~~~            |
  6 +                                    ~o   ~~~              +
    |                                 ~~~ o~~~~                |
    |                              ~~~      o                  |
y 4 +                           ~~~~                           +
    |       o       ~~o~~~~~ ~~~~                              |
    |     ~~~~    ~~~      ~~o                                 |
  2 +    ~~   ~  ~~                                            +
    |   ~~     o~                                              |
    |  o~                                                      |
    +----------+-------------+-------------+-------------+-----+
               2             4             6             8      
                                  x                             

NostalgiR documentation built on May 2, 2019, 2:45 p.m.