Learn R Programming

vrmlgen (version 1.4.9)

axis3d: Draw labeled coordinate axes in a 3D-scene

Description

axis3d draws 3 labeled, orthogonal coordinate axes in a 3D-scene in the VRML- or Livegraphics3D-format. Must be called after vrml.open() or lg3d.open() and before vrml.close() or lg3d.close().

Usage

axis3d(lab.axis = c("X-axis", "Y-axis", "Z-axis"), filename = NULL, type = "vrml", col.lab = "black", col.axis = "black", cex.lab = 1, local_scale = 1, global_scale = 1)

Arguments

lab.axis
a vector of size 3 containing the axis labels
filename
filename of the generated output file
type
the output type ("vrml" or "lg3d"), this will be set automatically if mesh3d is called after vrml.open() or lg3d.open()
col.lab
a vector of colors specifying the axis labels
col.axis
color of the axis
cex.lab
scaling factor for axis label font size
local_scale
a numerical scaling factor to increase/decrease the size of the plotted axes
global_scale
a numerical scaling factor applied to all objects in the 3D scene

Value

The function is used for its side-effect (writing coordinate axes to a VRML- or Livegraphics3D-file) and has no return value.

Details

axis3d adds colored and labeled coordinate axes to an already existing 3D- scene in the VRML- or Livegraphics3D-format. To create a standard scatter plot, bar plot or 3D mesh visualization, which already contains coordinate axes, the higher-level plotting functions cloud3d, bar3d and mesh3d provide more convenient alternatives. axis3d can only be applied within a VRML- or Livegraphics3D-environment created by calling the vrml.open() or lg3d.open() function and closed using the vrml.close() or lg3d.close() function.

References

Enrico Glaab, Jonathan M. Garibaldi, Natalio Krasnogor (2010). vrmlgen: An R Package for 3D Data Visualization on the Web. Journal of Statistical Software, 36(8), p. 1-18. URL: http://www.jstatsoft.org/v36/i08/

See Also

text3d, lines3d

Examples

Run this code


curdir <- getwd()
outdir <- tempdir()
setwd(outdir)

# start a new VRML environment
vrml.open(file = "axis_example.wrl", scale = 5,
          html.embed = "axis.html")

	# draw a coordinate system with dark blue axes
	# and dark gray axis labels
	axis3d(col.lab = "darkgray", col.axis = "darkblue")
	
	# plot random data points within the coordinate system
	# (increase point size by a factor of 2)
	mat <- matrix(runif(99, 0, 1), ncol = 3)
	points3d(mat, col = "red", scale = 2)

# close the VRML environment and write the output file
vrml.close()

# show the output in a web-browser 
# (VRML-plugin must be installed!)
if(file.exists(paste("file://",file.path(outdir,
                "axis.html"), sep = "")))
{
  browseURL(paste("file://",file.path(outdir,
                  "axis.html"), sep = ""))
}

setwd(curdir)

Run the code above in your browser using DataLab