Learn R Programming

barsurf (version 0.1.0)

barsurf: Bar Plots and Surface Plots in 3d

Description

Implements plots of discrete functions (bar plots) and continuous functions (surface plots) in 3D. Uses orthographic projection, a nonstandard fixed viewing angle, does not support detailed axes and is designed to be relatively minimal and simple, from a programming perspective. However, does support mixed bar sizes and multiple colors. Refer the vignette for better examples

Usage

plot3d.empty ()
plot3d.bar (x, y, z,
	main, xlab="x", ylab="y",
	col1=rgb (0, 0.8, 0.4), col2=rgb (0.5, 1, 0.7),
	zlim)
plot3d.surf (x, y, z,
	main, xlab="x", ylab="y",
	col1=rgb (0, 0.8, 0.4), col2="white",
	zlim)

Arguments

x

An optional vector of sorted x values. For bar plots, length(x) should equal nrow(z)+1. For surface plots, length(x) should equal nrow(z).

y

An optional vector of sorted y values. For bar plots, length(y) should equal ncol(z)+1. For surface plots, length(y) should equal ncol(z).

z

A matrix of z values. Increasing row indices correspond to increasing x values and increasing column indices correspond to increasing y values.

main

An optional main title.

xlab

The x label, defaults to x.

ylab

The y label, defaults to y.

zlim

An optional z range for the plot.

col1

The first color. For bar plots, may be a matrix.

col2

The second color. For bar plots, may be a matrix.

Details

Bar plots use two colors. The first color is the top of the bars and the second color is the front of the bars. Surface plots interpolate between two colors. Flatter regions are closer to the first color and steeper regions are closer to the second color.

Examples

Run this code
# NOT RUN {
#bar plot in 3d
#note the two commas
x = y = 1:4
f = function (x, y) x ^ 2 + y ^ 2
z = outer (x, y, f)
plot3d.bar (,,z)
# }

Run the code above in your browser using DataLab