plotVector {survSpearman} | R Documentation |
Plots a set of rectangles that represent a numeric vector.
Description
Plots a vector of numeric values as a set of rectangles with user specified height, width, color, and border color. The bases of the rectangles are aligned like in a histogram.
Usage
plotVector(vectValues, width, coordX, coordY, rotationRadians, vectColor, bordColor)
Arguments
vectValues |
The heights of the rectangles. If |
width |
The width (positive number) of the rectangles. It can be either one number or a vector of numbers with the same length as |
coordX |
X coordinate of the left base corner of the first rectangle, |
coordY |
Y coordinate of the left base corner of the first rectangle, |
rotationRadians |
By how much (in radians) to rotate the aligned rectangles around |
vectColor |
The colors of the rectangles in |
bordColor |
The color of the border of the rectangles. It can be either one value or a vector of values with the same length as |
Details
R
-function plot
has to be called first. The rectangles are aligned in the following manner. If rotationRadians
is zero, then the base of all rectangles is at coordY
. If vectValues[i]>=0
then the top of the rectangle is plotted at coordY
+ abs(vectValues[i])
. If the vectValues[i]
<0 then the bottom of the rectangle is plotted at coordY
- abs(vectValues[i])
. If rotationRadians
is not zero, then the aligned rectangles are rotated counter clock-wise around point (coordX
,coordY
).
Value
None
Author(s)
Svetlana K Eden, svetlanaeden@gmail.com
Examples
### Histogram-like plot
plot(c(-1, 2), c(-1, 1), type = "n")
vectValues = c(0.057, 0.336, 0.260, 0.362, 0.209)
plotVector(vectValues, width = 0.2, coordX = 0, coordY = 0, rotationRadians = 0,
vectColor = "gray", bordColor = "white")
### Rotated and flipped sequence of rectangles.
width = c(0.10, 0.20, 0.10, 0.80, 0.12)
vectColor = c("orange", "green", "orchid", "blue", "goldenrod1")
plot(c(-1, 2), c(-1, 2), type = "n")
plotVector(vectValues = vectValues, width, coordX = 0, coordY = 0,
rotationRadians = pi/2, vectColor, bordColor = "white")
plotVector(vectValues = -vectValues, width, coordX = 0, coordY = 0,
rotationRadians = 0, vectColor, bordColor = "white")
### Histogram-like plot with positive and negative values.
vectValues = c(0.057, -0.336, 0.260, -0.222, 0.209)
plot(c(-1, 1), c(-1, 1), type = "n")
vectColor = rep("goldenrod1", length(vectValues))
vectColor[vectValues<0] = "royalblue1"
bordColor = rep("red", length(vectValues))
bordColor[vectValues<0] = "darkblue"
plotVector(vectValues, width = 0.4, coordX = -1, coordY = 0, rotationRadians = 0,
vectColor, bordColor = bordColor)