Re: [R] Plotting MDS (multidimensional scaling)

From: Jari Oksanen <>
Date: Sun, 03 Apr 2011 06:22:12 +0000

Daniel Malter <daniel <at>> writes:

> Let's say I have an equilateral triangle. Then, the three Euclidean
> distances between points A, B, and C are all equal. That is,
> dist(AB)=dist(AC)=dist(BC). Let the points A, B, and C have
> (x,y)-coordinates (0,0), (2,0), and (1,sqrt(3)). Then, MDS should reproduce
> an equilateral triangle, which it does if there are only three points.
> require(MASS)
> x=c(0,2,1,0,0,sqrt(3))
> dim(x)=c(3,2)
> d1=dist(x)
> fit1<-isoMDS(d1)
> plot(fit1$points, xlab="Coordinate 1", ylab="Coordinate 2",
> main="Metric MDS",type="n")
> text(fit1$points, labels = c('A','B','C'), cex=1)
> So far so good, until I add more points. Now assume, I add a fourth point D
> at {0,2*sqrt(3)}. This produces the rectangular triangle ABD with
> hypothenuse BD that encompasses the smaller triangle ABC such that C lies in
> the middle between B and D. Then, MDS should reproduce the rectangular
> triangle ABD and the equilateral triangle ABC within it. However, even
> though distance matrix d2 below still indicates that ABC is an equilateral
> triangle, the plot of the MDS does not confirm this.
> x=c(0,2,1,0,0,0,sqrt(3),2*sqrt(3))
> dim(x)=c(4,2)
> d2=dist(x)
> fit2<-isoMDS(d2)
> plot(fit2$points, xlab="Coordinate 1", ylab="Coordinate 2",
> main="Metric MDS",type="n")
> text(fit2$points, labels = c('A','B','C','D'), cex=1)

Mario Valle already told you about asp=1 in plot() to force equal aspect ratio, and MASS also has eqscplot() function for plots with geometrically equal scaling. However, your example above hints that there is something else you should take care of: You label your plot as "Metric MDS", but isoMDS does not do metric MDS. The title in its documentation reads "Kruskal's Non-metric Multidimensional Scaling". In this case you happened to have metric MDS, because isoMDS uses metric scaling as its default starting configuration, and in this case that starting configuration is a perfect fit (stress = 0), and isoMDS() makes no iterations to change the starting configuration. If you want to work with metric MDS, use cmdscale() which does metric MDS.

Cheers, jari Oksanen

> The reason for this is that the dimension of the plot is automatically
> scaled to fit the points. This distorts the visual impression of the
> distances, angular relationships, and relative locations. If you plot on a
> square pane, however, peace and order are restored in the galaxy.
> plot(fit2$points, xlab="Coordinate 1", ylab="Coordinate 2",
> main="Metric MDS",type="n",xlim=c(-3,3),ylim=c(-3,3))
> text(fit2$points, labels = c('A','B','C','D'), cex=1)
> Best,
> Daniel
> --
> View this message in context:
> Sent from the R help mailing list archive at
> mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sun 03 Apr 2011 - 06:31:53 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 03 Apr 2011 - 21:10:27 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive