irritable_phd_syndrome
irritable_phd_syndrome

Reputation: 5067

R: getting axis labels on parallel coordinates plot

I am having difficulty trying to get labels on my parcoord() plot. If I do :

library(MASS)
data1<-cbind.data.frame("A"=rbind(6,9,10))
data2<-cbind.data.frame("B"=rbind(3,19,1))
parcoord(cbind(data1,data2), col=1, lty=1)
axis(2, at=c(6,9,10), labels=c("this","should","bealabel"))

I do not get labels the left hand side of the plot. How do I fix this?

Upvotes: 1

Views: 1060

Answers (1)

Zheyuan Li
Zheyuan Li

Reputation: 73265

Because y-axis has been rescaled to [0,1]. Simply try axis(2) to see what the default axis is. Therefore, when you do at = c(6, 9, 10), that is beyond the range hence not displayed. Here is a solution:

y <- c(6, 9, 10)
pos <- (y - min(y)) / diff(range(y))  ## rescaling
parcoord(cbind(data1,data2), col=1, lty=1)
axis(2, at=pos, labels=c("this","should","bealabel"))

enter image description here

Upvotes: 2

Related Questions