0

I use the code below to make a graph:

# open the pdf file
pdf(file='LSF1_PWD_GWD.pdf')
a <- c('LSF1', 'PWD', 'GWD')
rowsToPlot<-c(1,3,4)
matplot(as.matrix(t(tbl_alles[rowsToPlot,])),type=rep("l", length(rowsToPlot)), col=rainbow(length(rowsToPlot)),xlab = 'Fraction Size', ylab = 'Intensity')
legend('topright',a,lty=1, bty='n', cex=.75, col = rainbow(length(rowsToPlot)))
# close the pdf file
dev.off()

but I "don't like" the names on the X axis. The scale is fine but I would like to change the numbers from 1:25 to the vector name_xaxis.

> name_xaxis
 [1] "10"      "33.95"   "58.66"   "84.42"   "110.21"  "134.16"  "164.69"  "199.1"   "234.35"  "257.19"  "361.84"  "432.74"  "506.34" 
[14] "581.46"  "651.71"  "732.59"  "817.56"  "896.24"  "971.77"  "1038.91"

but keep the scale !

Can you help me with that ?

My data:

> dput(head(tbl_alles))
structure(list(`10` = c(0, 0, 0, 0, 0, 0), `33.95` = c(0, 0, 
0, 0, 0, 0), `58.66` = c(0, 0, 0, 0, 0.406068869, 0.442796386
), `84.42` = c(0, 1, 0, 0, 1, 1), `110.21` = c(0, 0.740141948, 
0, 0, 0, 0), `134.16` = c(0.145120216, 0, 0, 0, 0, 0), `164.69` = c(0.469210651, 
0, 0.718559026, 0, 0, 0), `199.1` = c(1, 0, 0.407942079, 0, 0, 
0), `234.35` = c(0.872554735, 0, 0.36848211, 0, 0, 0), `257.19` = c(0.607531831, 
0, 0.732164761, 0, 0, 0), `361.84` = c(0.448884106, 0.915113972, 
1, 0, 0, 0), `432.74` = c(0.527332473, 1, 0.638970429, 0, 0, 
0), `506.34` = c(0, 0, 0, 0, 0, 0), `581.46` = c(0, 1, 0.51988094, 
0, 0, 0), `651.71` = c(0, 0.57768664, 0.61355208, 0.56951949, 
0, 0), `732.59` = c(0, 0.53256077, 0.66151388, 0.3963868, 0, 
0), `817.56` = c(0, 0.44040018, 1, 0.74806138, 0, 0), `896.24` = c(0, 
0.591717841, 0.967059269, 0.801504496, 0, 0), `971.77` = c(0, 
0, 0.863936222, 0.783134862, 0, 0), `1038.91` = c(0, 0, 0.83156426, 
1, 0, 0)), .Names = c("10", "33.95", "58.66", "84.42", "110.21", 
"134.16", "164.69", "199.1", "234.35", "257.19", "361.84", "432.74", 
"506.34", "581.46", "651.71", "732.59", "817.56", "896.24", "971.77", 
"1038.91"), row.names = c("at1g01050.1", "at1g01080.1", "at1g01090.1", 
"at1g01320.2", "at1g01470.1", "at1g01800.1"), class = "data.frame")

enter image description here

Shaxi Liver
  • 1,052
  • 3
  • 25
  • 47

1 Answers1

1

Something like this should work:

a <- matrix(rnorm(100), ncol=2)
matplot(a, xaxt="n")
axis(1, at=seq(1, 50, 5), labels=paste("A", seq(1, 50, 5)))

Edit 1:

Would this work?

a <- c('LSF1', 'PWD', 'GWD')
rowsToPlot<-c(1,3,4)
name_xaxis <- c(10, 33.95, 58.66, 84.42)

matplot(
    as.matrix(t(tbl_alles[rowsToPlot,])),
    type=rep("l", length(rowsToPlot)),
    col=rainbow(length(rowsToPlot)),
    xlab = 'Fraction Size',
    ylab = 'Intensity',
    xaxt="n")

legend('topright',a,lty=1, bty='n', cex=.75, col = rainbow(length(rowsToPlot)))

axis(1, at=name_xaxis)
johannes
  • 14,043
  • 5
  • 40
  • 51
  • Can you just edit your answer using my data ? I am not really sure how I should do that. – Shaxi Liver Oct 01 '14 at 13:55
  • Sure, if you can provide a [reproducible exmpale](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – johannes Oct 01 '14 at 14:28
  • Added my data + the graph. Of course you will use different rows because I can't put my whole data here so the appearance of the graph might be different. – Shaxi Liver Oct 01 '14 at 15:25