Domanda

I made 13 parallel coordinate plots lines, where each plot has x lines, each of 5 points. There are three things that I would like to change:

  1. I would like to remove very long vertical x-axis ticks that protrude below out of the graph
  2. I would like to change the x-axis labels of each plot to be "N", "1", "2", "3", "4"
  3. I would like the y-axis to be labelled for each plot. It currently is not. The maximum y-value for each plot is max(input). So, I like four y-axis labels: max(input), 3/4 max(input), 1/2 max(input), and 1/4 max(input) (all to the nearest integer to keep it neat).
  4. I would like a main title over all the graphs (I'll just call it "Main Title" for now)

Here is my code currently:

par(mfrow = c(3,5))
par(mar=c(0.1,0.1,0.1,0.1))
# For each color (cluster) in the random network
for (i in 1:max(net$colors)){
  color = mergedColors[which(net$colors == i)[1]]
  input = countTable[which(net$colors==i),]
  parcoord(input, lty = 1, var.label = FALSE, col = color)
}

where the str(input) is a data.frame of x observations of 5 variables.

I tried to add things like x.label = c("N","1","2","3","4"), but that did not work.

Edit:

Here is some sample data, as per suggestions. Please let me know if I should include anything else:

net <- data.frame(colors=as.numeric(sample(1:15, 100, replace = T)))

mycols <- c("brown", "blue", "turquoise", "greenyellow", "red", 
    "pink", "green", "yellow", "magenta", "black","purple",      
    "tomato1","peachpuff","orchid","slategrey")
mergedColors = mycols[net$colors]

countTable <- data.frame(matrix(sample(1:100,100*5, replace=T), 
    ncol=5, dimnames=list(NULL, c("Norm","One","Two","Three","Four"))))
È stato utile?

Soluzione

OK. I'm not sure I understand request 1, but here's what I came up with so far

library(MASS)

opar<-par(no.readonly=T)
par(mfrow = c(3,5))
par(oma=c(1.2,2,2,0))
par(mar=c(2,2,0.1,0.1))
# For each color (cluster) in the random network
for (i in 1:max(net$colors)){
  color = mergedColors[which(net$colors == i)]
  input = countTable[which(net$colors==i),]
  colnames(input)<-c("N",1:4)
  parcoord(input, lty = 1, var.label = FALSE, col = color)
  axis(2,at=seq(0,1,length.out=5),labels=seq(min(input),max(input), length.out=5))
}
mtext("Main Title",3, outer=T)
par(opar)

sample plot

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top