##
## Example 1
## Computing and ploting a bpca object with 'graphics' package - 2d
##
bp <- bpca(gabriel1971)
dev.new(w=6, h=6)
oask <- devAskNewPage(dev.interactive(orNone=TRUE))
plot(bp,
var.factor=2)
# Additional graphical parameters (nonsense)
plot(bpca(gabriel1971,
meth='sqrt'),
main='gabriel1971 - sqrt',
sub='The graphical parameters are working fine!',
var.factor=2,
var.cex=.6,
var.col=rainbow(9),
var.pch='v',
obj.pch='o',
obj.cex=.5,
obj.col=rainbow(8),
obj.pos=1,
obj.offset=.5)
##
## Example 2
## Computing and plotting a bpca object with 'scatterplot3d' package - 3d
##
bp <- bpca(gabriel1971,
d=1:3)
plot(bp,
var.factor=3)
# Additional graphical parameters (nonsense)
plot(bpca(gabriel1971,
d=1:3,
meth='jk'),
main='gabriel1971 - jk',
sub='The graphical parameters are working fine!',
var.factor=6,
var.pch='+',
var.cex=.6,
var.col='green4',
obj.pch='*',
obj.cex=.8,
obj.col=1:8,
ref.lty='solid',
ref.col='red',
angle=70)
##
## Example 3
## Computing and plotting a bpca object with 'rgl' package - 3d
##
plot(bpca(gabriel1971,
d=1:3),
rgl.use=TRUE,
var.factor=2)
# Suggestion: Interact with the graphic with the mouse
# left button: press, maintain and movement it to interactive rotation;
# right button: press, maintain and movement it to interactive zoom.
# Enjoy it!
if (FALSE) {
##
## Example 4
## Grouping objects with different symbols and colors - 2d and 3d
##
# 2d
plot(bpca(iris[-5]),
var.factor=.3,
var.cex=.7,
obj.names=FALSE,
obj.cex=1.5,
obj.col=c('red', 'green3', 'blue')[unclass(iris$Species)],
obj.pch=c('+', '*', '-')[unclass(iris$Species)])
# 3d static
plot(bpca(iris[-5],
d=1:3),
var.factor=.2,
var.color=c('blue', 'red'),
var.cex=1,
obj.names=FALSE,
obj.cex=1,
obj.col=c('red', 'green3', 'blue')[unclass(iris$Species)],
obj.pch=c('+', '*', '-')[unclass(iris$Species)])
# 3d dynamic
plot(bpca(iris[-5],
method='hj',
d=1:3),
rgl.use=TRUE,
var.col='brown',
var.factor=.3,
var.cex=1.2,
obj.names=FALSE,
obj.cex=.8,
obj.col=c('red', 'green3', 'orange')[unclass(iris$Species)],
simple.axes=FALSE, box=TRUE)
##
## Example 5
## Computing and plotting a bpca object with 'obj.identify=TRUE' parameter - 2d
##
bp <- bpca(gabriel1971)
# Normal labels
if(interactive())
plot(bp,
obj.names=FALSE,
obj.identify=TRUE)
# Alternative labels
if(interactive())
plot(bp,
obj.names=FALSE,
obj.labels=c('toi', 'kit', 'bat', 'ele', 'wat', 'rad', 'tv', 'ref'),
obj.identify=TRUE)
##
## Example 6
## Computing and plotting a bpca object with 'obj.identify=TRUE' parameter - 3d
##
bp <- bpca(gabriel1971,
d=1:3)
# Normal labels
if(interactive())
plot(bp,
obj.names=FALSE,
obj.identify=TRUE)
# Alternative labels
if(interactive())
plot(bp,
obj.names=FALSE,
obj.labels=c('toi', 'kit', 'bat', 'ele', 'wat', 'rad', 'tv', 'ref'),
obj.identify=TRUE)
##
## New options plotting
##
plot(bpca(ontario))
# Labels for all objects
(obj.lab <- paste('g',
1:18,
sep=''))
# Giving obj.labels
plot(bpca(ontario),
obj.labels=obj.lab)
# Evaluate an object (1 is the default)
plot(bpca(ontario),
type='eo',
obj.cex=1)
plot(bpca(ontario),
type='eo',
obj.id=7,
obj.cex=1)
# Giving obj.labels
plot(bpca(ontario),
type='eo',
obj.labels=obj.lab,
obj.id=7,
obj.cex=1)
# The same as above
plot(bpca(ontario),
type='eo',
obj.labels=obj.lab,
obj.id='g7',
obj.cex=1)
# Evaluate a variable (1 is the default)
plot(bpca(ontario),
type='ev',
var.pos=2,
var.cex=1)
plot(bpca(ontario),
type='ev',
var.id='E7',
obj.labels=obj.lab,
var.pos=1,
var.cex=1)
# A complete plot
cl <- 1:3
plot(bpca(iris[-5]),
type='ev',
var.id=1,
var.fac=.3,
obj.names=FALSE,
obj.col=cl[unclass(iris$Species)])
legend('topleft',
legend=levels(iris$Species),
text.col=cl,
pch=19,
col=cl,
cex=.9,
box.lty=0)
# Compare two objects (1 and 2 are the default)
plot(bpca(ontario),
type='co',
c.radio=.4,
c.color='blue',
c.lwd=2)
plot(bpca(ontario),
type='co',
obj.labels=obj.lab,
c.radio=.5,
c.color='blue',
c.lwd=2)
plot(bpca(ontario),
type='co',
obj.labels=obj.lab,
obj.id=13:14)
plot(bpca(ontario),
type='co',
obj.labels=obj.lab,
obj.id=c('g7',
'g13'))
# Compare two variables
plot(bpca(ontario),
type='cv',
c.number=3,
c.radio=1.5)
# Which won where/what
plot(bpca(ontario),
type='ww')
# Discrimitiveness vs. representativeness
plot(bpca(ontario),
type='dv')
plot(bpca(ontario),
type='dv',
c.number=4,
c.radio=1)
# Means vs. stability
plot(bpca(ontario),
type='ms')
plot(bpca(ontario),
type='ms',
c.number=3)
# Rank objects with ref. to the ideal variable
plot(bpca(ontario),
type='ro')
plot(bpca(ontario),
type='ro',
c.number=6,
c.radio=.5)
# Rank variables with ref. to the ideal object
plot(bpca(ontario),
type='rv')
plot(bpca(ontario),
type='rv',
c.number=6,
c.radio=.5)
plot(bpca(iris[-5]),
type='eo',
obj.id=42,
obj.cex=1)
plot(bpca(iris[-5]),
type='ev',
var.id='Sepal.Width')
plot(bpca(iris[-5]),
type='ev',
var.id='Sepal.Width',
var.factor=.3)
}
devAskNewPage(oask)
Run the code above in your browser using DataLab