PlotFunctions {fBasics} | R Documentation |
A collection and description of several plot functions
and utilities which may be useful for the explorative
data analysis of financial and economic market data using
S4 time series objects from Rmetrics. Included are also
utility functions displaying tables for characters, plot
symbols, and colors.
The functions are:
tsPlot | Time Series Plot, |
histPlot | Histogram Plot of (Series) Data, |
densityPlot | Kernel Density Estimate Plot, |
circlesPlot | Scatterplot of Circles Indexing a 3rd Variable, |
perspPlot | Perspective Plot in 2 Dimensions, |
perspPlot | Contour Plot in 2 Dimensions, |
characterTable | Table of Numerical Equivalents to Latin Characters, |
plotcharacterTable | Table of plot characters, plot symbols, |
colorTable | Table of Color Codes and Plot Colors itself, |
greyPal | Creates a grey palette like rainbow does for colors, |
splusLikePlot | Scales plotting and symbols. |
tsPlot(x, ...) histPlot(x, col = "steelblue4", border = "white", main = x@units, add.fit = TRUE, ...) densityPlot(x, col = "steelblue4", main = x@units, add.fit = TRUE, ...) circlesPlot(x, y, size = 1, ...) perspPlot(x, y, z, theta = -40, phi = 30, col = "steelblue4", ps = 9, ...) contourPlot(x, y, z, ...) characterTable(font = 1, cex = 0.7) plotcharacterTable(font = par('font'), cex = 0.7) colorTable(cex = 0.7) greyPal(n = 64, start = 255-n, end = 255)
add.fit |
[histPlot][densityPlot] - a logical flag, if set to TRUE which is the default
value than a normal fit will be added to the plot, otherwise
not.
|
col, border |
two character strings, defining the colors used to fill the
bars and to plot the borders of the bars for the histPlot ,
or color and linetype as used by the function plot .
|
font, cex |
an integer value, the number of the font , by default font
number 1, the standard font for the characterTable
or the current plot character font for the
plotcharacterTable . The character size is determined by
the numeric value cex , the default size is 0.7.
|
main |
character string of main title(s). |
n, start, end |
[greyPal] - cr
n gives the number of greys to be constructed,
start and end span the range of the color palette.
By default 64 grey tones equidistant chosen from the color range
(191, 191, 191) to (255, 255, 255).
|
size |
a numeric vector like z , the third variable in the
function circlesPlot . The argument gives the size of the
circles, by default all values are set to 1.
|
theta, phi, ps |
plot parameters for the function perspPlot as used by the
function persp .
|
x, y |
[tsPlot][histPlot][densityPlot] - an object of class timeSeries .
[circlesPlot][perspPlot] - numeric vectors. In the case of the thermometerPlot x holds the
current values of the n-bars.
|
z |
a matrix containing the values to be plotted by the function
perspPlot .
|
... |
arguments to be passed to the underlying plot function. |
Series Plots:
tsPlot
plots time series on a common plot. Unlike plot.ts
the series can have a different time bases, but they should have the
same frequency. tsPlot
is a synonyme function call for R's
ts.plot
from the the ts
package.
Histogram and Density Plots:
histPlot
and densityPlot
show (return) distributions in form
of a histogram and density plots. The first is a synonyme function call
for R's histogram plot, calling the function hist
. The outlook
of the plot is more SPlus like. The second creates a density Plot
with underlying kernel density estimation. It is a function call to
R's density
function.
Three Dimensional Plots:
circlesPlot
and perspPlot
, see also contour
,
are functions to plot 3 dimensional data sets. The first is
simple scatterplot with points replaced with variable circles,
whose size indexes a third variable. The second aloows to create
a perspective 3 dimensional plot. It is a function call to R's
persp
plot, but the parameters are setted to produce a
more SPlis like outlook of the plot. contour
is the call
to R's contour plot from the base
package.
Plot Utilities:
characterTable
, plotcharacterTable
and colorTable
are three helpful utilities for using characters and colors in plots.
The first function displays a table of numerical equivalents to Latin
characters, the second displays a table of plot characters, i.e.
the symbols used in plots, and the third displays a table with the
codes of the default plot colors.
tsPlot
plots a time series. Just a synonyme call to the function
ts.plot
changing plot type to l
ines and plot color
to steelblue3
.
histPlot
plots a histogram. This is a synonyme function call for R's
histogram plot, calling the function hist
. Returns an
object of class "histogram"
, see hist
.
densityPlot
returns an object of class "density"
, see density
.
circlesPlot
a simple pseudo three dimensional scatterplot of circels whose
sizes index a thrid variable.
perspPlot
contourPlot
draws perspective or contour plots of surfaces over the x-y plane.
characterTable
displays a table with the characters of the requested font.
The character on line "xy" and column "z" of the table has
code "\xyz"
, e.g cat("\126")
prints: V for font
number 1. These codes can be used as any other characters.
plotcharacterTable
displays a table with the plot characters numbered from 0 to 255.
colorTable
displays a table with the plot colors with the associated color number.
Gordon Smyth for the circlesPlot,
Pierre Joyet for the characterTable, and
Diethelm Wuertz for the Rmetrics R-port.
## SOURCE("fBasics.12B-PlotFunctions") ## Not run: ## tsPlot - xmpBasics("\nStart: European Stock Markets > ") # Show multiple plot: par(mfrow = c(1, 1), cex = 0.7) data(DowJones30) DowJones.ts = as.timeSeries(DowJones30)[, c("CAT", "GE", "IBM", "JPM", )] tsPlot(DowJones.ts) title(main = "CAT - GE - IBM - JPM") ## histPlot - xmpBasics("\nNext: Histogram Plot of Normal Random Numbers > ") DowJones.ret = returnSeries(DowJones.ts) par(mfrow = c(2, 2), cex = 0.7) histPlot(x = DowJones.ret) ## densityPlot - xmpBasics("\nNext: Density Plot of Normal Random Numbers > ") densityPlot(x = DowJones.ret) ## circlesPlot - xmpBasics("\nNext: 3D Circles Plot of Normal Random Numbers > ") par(mfrow = c(1, 1), cex = 0.7) circlesPlot(x = rnorm(50), y = rnorm(50), size = abs(rnorm(50)), main = "Circles Plot") ## perspPlot - xmpBasics("\nNext: Perspective Plot > ") par(mfrow = c(1, 1)) x = y = seq(-10, 10, length = 51) f = function(x, y) { r = sqrt(x^2+y^2); 10 * sin(r)/r } z = outer(x, y, f) perspPlot(x, y, z) title(main = "Perspective Plot", line = -3) ## characterTable - xmpBasics("\nNext: Print the Copyright Sign > ") cat("\251 \n") ## characterTable - xmpBasics("\nNext: Display Character Table for Symbol Font > ") characterTable(5) ## colorTable - xmpBasics("\nNext: Display Table of Plot Colors > ") colorTable() ## plotcharacter Table - xmpBasics("\nNext: Display Table of Plot Characters > ") plotcharacterTable() ## End(Not run)