[R] changing x and y ranges in a PCA plot created by library(labdsv)

David Winsemius dwinsemius at comcast.net
Mon Aug 8 23:22:33 CEST 2016


> On Aug 8, 2016, at 12:48 AM, Mohsen Sharafatmandrad <mohsen.sharafatmandrad at gmail.com> wrote:
> 
> I want to change x and y ranges in a PCA plot created by library(labdsv).
> When I run "plot(o.pca, xlim=c(-2, 3), ylim=c(-2, 4))", nothing will
> change. Script is as fallow:
> 
> 
> 
> raw<- matrix(c(1,2,2.5,2.5,1,0.5,0,1,2,4,3,1),nrow=6)
> 
> colnames(raw)<- c("s1","s2")
> 
> rownames(raw)<- c("r1","r2","r3","r4","r5","r6")
> 
> cent<- scale(raw,scale=FALSE)
> 
> o.pca <- pca(cent)
> 
> plot(o.pca)
> 
> plot(o.pca, xlim=c(-2,3), ylim=c(-2,4))

You got a response yesterday telling you that xlim and ylim are not passed to the plot call from plot.

You can see this yourself by examining the code:

labdsv::plot.pca
function (x, ax = 1, ay = 2, col = 1, title = "", pch = 1, ...) 
{
    if (class(x) != "pca") 
        stop("You must specify a an object of class pca")
    plot(x$scores[, ax], x$scores[, ay], asp = 1, col = col, 
        xlab = paste("PCA", ax), ylab = paste("PCA", ay), pch = pch, 
        main = title)
    invisible()
}
<environment: namespace:labdsv>



> -- 
> Cheers
> 
> Mohsen Sharafatmandrad
> 
> 	[[alternative HTML version deleted]]

Please read the Posting guide and post any follow-ups in plain text.


-- 

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list