## print & plot methods for ishihara object
plot.ishihara<-function(x,...){
if(hasArg(mar)) mar<-list(...)$mar
else mar<-rep(2.1,4)
if(hasArg(numbers)) numbers<-list(...)$numbers
else numbers<-FALSE
if(hasArg(alpha)) alpha<-list(...)$alpha
else alpha<-1.0
xx<-sapply(x,function(x) x$x)
yy<-sapply(x,function(x) x$y)
rr<-sapply(x,function(x) x$radius)
color<-sapply(x,function(x) x$color)
ii<-setdiff(1:attr(x,"nshapes"),attr(x,"pattern"))
color[ii]<-sapply(color[ii],function(x,alpha)
make.transparent(x,alpha),alpha=alpha)
par(mar=mar)
lims<-c(0,300)
plot.new()
plot.window(xlim=lims,ylim=lims,asp=1)
symbols(x=xx,y=yy,circles=rr,bg=color,fg=color,
inches=FALSE,add=TRUE)
if(numbers) text(x=xx,y=yy,1:attr(x,"nshapes"),cex=0.5)
box()
}
print.ishihara<-function(x,...){
if(hasArg(show.hidden)) show.hidden<-list(...)$show.hidden
else show.hidden<-FALSE
cat("\n Object of class \"ishihara\" containing",
attr(x,"nshapes"),"shapes.\n\n")
if(show.hidden)
cat(paste(" Hidden number, character, or figure is: ",
attr(x,"hidden"),".\n",sep=""))
else cat(paste(" To reveal hidden number, character, or figure",
"\n print with show.hidden=TRUE.\n"))
cat("\n")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.