Plot tick level control
-
16-06-2021 - |
Question
Here is my question:
myd <- data.frame (V1 = paste ("V", 1:1000), V2 = rnorm(1000))
plot(myd[,1], myd[,2])
As my plot is busy in axis, I want to just put tick markers at every 100 and display corresponding labels. Also tick only (without label) is displayed at between two hundred ticks. For example, ticks and labels at 1, 100, 200, 300.....1000, ticks only at 50, 150, 250, 350 ......950
How I can I achieve this ?
Edit:
Example :
| | | | | | |
V1 V100 V200 V300
Solution
You could use:
plot(myd[,1], myd[,2], xaxt="n")
axis(1, at=seq(0,1000,50))
also have a look at ?axis
for details about ticks and labels.
Updated answer
axis(1, at=seq(0,1000,100), label=paste0("V", seq(0, 1000, 100)))
axis(1, at=seq(50,1000,100), label=F, tick=T)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow