1

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"))))
MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • 1
    Please supply sample data as described in [this question](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) so that we can actually run your code to see what you are looking at. – MrFlick May 09 '14 at 04:44
  • Someone else also asked recently about parcoord. You may be interested in my answer there as well: [add ticks to parcoord](http://stackoverflow.com/questions/23553210/add-ticks-to-parcoord-parallel-coordinates-plot/) – MrFlick May 09 '14 at 04:45
  • What about using ggplot2 with the options `xlim()`, `xlab()` and `facet()` – ramesh May 09 '14 at 04:50
  • thanks MrFlick, I added sample data :) –  May 09 '14 at 05:11
  • Ramesh: As you can see by my sample data, I don't have much experienced programming. I will keep trying... –  May 09 '14 at 05:12
  • @user2808302 Thank you for posting the sample code. I reduced it and made it better match the actual plotting code you were running. If I misinterpreted anything, please correct. – MrFlick May 09 '14 at 06:26

1 Answers1

2

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

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • This inspires me to improve my plot-making skills. Thank you so much! –  May 09 '14 at 13:20