Say here is my code:
plot(data ylab="x", xlab="y", xlim=c(1, 13))
But the x-axis of the plot presented like this:

As you see, the x-axis presented from 2 to 12 by 2. However, I want it shown from 1 to 13 by 1 step, how can I realize that?
You've defined the limits for your axis; however, R is inserting the "default" values for it.
To alter them, you need to
xaxt='n'So, let's get it done!
plot(data, ylab="x", xlab="y", xlim=c(1, 13), xaxt='n')
# Now, define a custom axis
axis(side = 1, at=1:13)
This will give you what you want.
From the documentation, axis():
Description
Adds an axis to the current plot, allowing the specification of the side, position, labels, and other options.
Usage
axis(side, at = NULL, labels = TRUE, tick = TRUE, line = NA, pos = NA, outer = FALSE, font = NA, lty = "solid", lwd = 1, lwd.ticks = lwd, col = NULL, col.ticks = NULL, hadj = NA, padj = NA, ...)
Some of the most used arguments are:
side (integer) 1=below, 2=left, 3=above and 4=right.at (vector) position of the tick markslabels (vector) labels for the tick marks. The vector must be the same size of at. If ommited, the values of at will be used. FALSE hides any labelsUseful reference:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With