[R] how can I control the x-axis tick labels
Don MacQueen
macq at llnl.gov
Mon Jun 7 06:51:55 CEST 2010
Try:
plot( , xaxt='n', )
axis(1, at=c(1,2,3,4,5, ... all the rest of them ...) )
You might also need to use the label argument to axis()
-Don
At 5:18 AM +0200 6/7/10, <mauede at alice.it> wrote:
>I am trying to generate a plot whose x-axis values are the following:
>
> data_out[,1]
> [1] 1979 1958 1937 1916 1895 1874 1853 1832 1811 1790 1769 1748
>1727 1706 1685 1664 1643 1622 1601 1580 1559
> [22] 1538 1517 1496 1475 1454 1433 1412 1391 1370 1349 1328 1307
>1286 1265 1244 1223 1202 1181 1160 1139 1118
> [43] 1097 1076 1055 1034 1013 992 971 950 929 908 887 866
>845 824 803 782 761 740 719 698 677
> [64] 656 635 614 593 572 551 530 509 488 467 446 425
>404 383 362 341 320 299 278 257 236
> [85] 215 194 173 152 131 110 89 68 47 26 25 24
>23 22 21 20 19 18 17 16 15
>[106] 14 13 12 11 10 9 8 7 6 5 4 3 2 1
>
>The y-axis values are:
>
>> data_out[,2]
> [1] 1.01709 1.09454 1.16331 1.21673 1.26098 1.30297 1.33905
>1.37466 1.40690 1.43407 1.46022
> [12] 1.48497 1.50939 1.53382 1.55764 1.58068 1.60422 1.62692
>1.64918 1.67210 1.69456 1.71653
> [23] 1.73706 1.75634 1.77562 1.79505 1.81393 1.83259 1.85197
>1.87105 1.88949 1.90792 1.92649
> [34] 1.94479 1.96263 1.98029 1.99677 2.01212 2.02692 2.04183
>2.05648 2.07071 2.08329 2.09510
> [45] 2.10593 2.11636 2.12563 2.13423 2.14317 2.15116 2.15739
>2.16426 2.17121 2.17796 2.18490
> [56] 2.19103 2.19751 2.20357 2.21056 2.21642 2.22264 2.22861
>2.23448 2.24007 2.24601 2.25113
> [67] 2.25593 2.25842 2.26077 2.26183 2.26223 2.26224 2.26133
>2.25868 2.25493 2.25130 2.24704
> [78] 2.24123 2.23236 2.22251 2.20842 2.19076 2.17490 2.15480
>2.13716 2.11967 2.10428 2.08815
> [89] 2.07497 2.06104 2.05527 2.05412 2.06270 2.08828 2.09092
>2.09158 2.09290 2.09495 2.09370
>[100] 2.09703 2.10551 2.10771 2.10916 2.11557 2.12741 2.13782
>2.14946 2.16577 2.18978 2.21518
>[111] 2.25129 2.27978 2.32903 2.40820 2.50683 2.64452 3.06182
>3.97841 35.81950
>
>I cannot get my ploy start with the tick label "1". Surprisingly it
>keeps starting from 0 regardless of the usage of the graphic
>parameter xlim.
>I tried many different combinations of the parameters appearing in
>the plot instruction.
>I also tried to sort the x-axis value in increasing order.
>
>>
>>plot(sort(data_out[,1]),sort(data_out[,2],decreasing=T),xlim=c(1,1979),ylim=c(1,35),main="Intrinsic
>>Dimensionality of 2D Swiss
>>Roll",font.main=2,cex.main=1.5,col.main="red",xlab="Number of
>>Nearest-Neighbors",ylab="Dimension",type="l",lab=c(10,10,3))
>
>How can I get the x-axis tick labels to be (a subset of) the x-axis
>values, that is:
>
> 1 2 3 4 5 6 7 8 9 10 11 12 13 14
>15 16 17 18 19 20 21
> 22 23 24 25 26 47 68 89 110 131 152 173 194 215
>236 257 278 299 320 341 362
> 383 404 425 446 467 488 509 530 551 572 593 614 635
>656 677 698 719 740 761 782 803
> 824 845 866 887 908 929 950 971 992 1013 1034 1055 1076
>1097 1118 1139 1160 1181 1202 1223 1244
>1265 1286 1307 1328 1349 1370 1391 1412 1433 1454 1475 1496 1517
>1538 1559 1580 1601 1622 1643 1664 1685
>1706 1727 1748 1769 1790 1811 1832 1853 1874 1895 1916 1937 1958 1979
>
>Thank you in advance,
>Maura
>
>
>tutti i telefonini TIM!
>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://*stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://*www.*R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.
--
---------------------------------
Don MacQueen
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
macq at llnl.gov
More information about the R-help
mailing list