Michael Friendly
2014-Feb-04 01:41 UTC
[R] parallel coordinate plot showing density of curves
Given a set of numeric variables and a group factor, as in the iris data used below, I`d like to show a parallel coordinate plot, where instead of trace lines, I want to show something of the density distribution of the variable values for each group. Some approximations to what I want are shown below, using lattice, and simple techniques to show density *visually*, varying the amount of "ink". I'd like to know if there is a *statistical* implementation that would do something like this, either in the lattice or ggplot2 families. (I'm sure there is, but any help with syntax would be appreciated.) library(lattice) data("iris") vnames <- c("Sepal\nLength", "Sepal\nWidth", "Petal\nLength", "Petal\nWidth") parallelplot(~iris[1:4], iris, groups = Species, varnames = vnames, horizontal.axis = FALSE, lwd=2, col=c("red", "blue", "green3")) # thicker line width parallelplot(~iris[1:4], iris, groups = Species, varnames = vnames, horizontal.axis = FALSE, lwd=4, col=c("red", "blue", "green3")) # use alpha-blennding parallelplot(~iris[1:4], iris, groups = Species, varnames = vnames, horizontal.axis = FALSE, lwd=8, col=c(rgb(1,0,0,.2), rgb(0,0,1,.2), rgb(0,205/255,0,.2) ) ) -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. & Chair, Quantitative Methods York University Voice: 416 736-2100 x66249 Fax: 416 736-5814 4700 Keele Street Web: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA
On 02/04/2014 12:41 PM, Michael Friendly wrote:> Given a set of numeric variables and a group factor, as in the iris data > used below, > I`d like to show a parallel coordinate plot, where instead of trace > lines, I want > to show something of the density distribution of the variable values for > each > group. > > Some approximations to what I want are shown below, using lattice, > and simple techniques to show density *visually*, varying the amount > of "ink". > > I'd like to know if there is a *statistical* implementation that would do > something like this, either in the lattice or ggplot2 families. (I'm sure > there is, but any help with syntax would be appreciated.) >Hi Michael, I may be completely off the track here, but just on the off chance... data(iris) library(plotrix) x11(width=6,height=10) oldpar<-panes(nrow=3,ncol=1) par(mar=c(5,4,4,2)) dendroPlot(iris[iris$Species=="setosa",1:4],breaks=list(10,10,10,10), setlabels=names(iris)[1:4],main="Setosa",xlab="Measurement",ylab="Cm") dendroPlot(iris[iris$Species=="versicolor",1:4],breaks=list(10,10,10,10), setlabels=names(iris)[1:4],main="Versicolor",xlab="Measurement",ylab="Cm") dendroPlot(iris[iris$Species=="virginica",1:4],breaks=list(10,10,10,10), setlabels=names(iris)[1:4],main="Virginica",xlab="Measurement",ylab="Cm") par(oldpar) Jim