I have two questions.
Here is my R code, with no success:
plot(0:10,0:10,type="n",axes=FALSE,xlab="JBL",ylab="PRAC")
axis(side=1,at=c("AL",1,2,3,4,5,6,7,8,9,"BL"),las=1)
axis(side=2,at=c("CL",1,2,3,4,5,6,7,8,9,"DL"),las=1)
box()
Add tick marks on an axisClick the chart, and then click the Chart Design tab. Click Add Chart Element > Axes > More Axis Options. On the Format Axis pane, expand Tick Marks, and then click options for major and minor tick mark types.
Minor tick labels can be turned on by setting the minor formatter. MultipleLocator places ticks on multiples of some base. StrMethodFormatter uses a format string (e.g., '{x:d}' or '{x:1.2f}' or '{x:1.1f} cm' ) to format the tick labels (the variable in the format string must be 'x' ).
Select the Enable Minor Labels check box to display minor tick labels. Select the Minor Labels on Major Ticks check box to display both a minor tick label and a major tick label for each major tick.
For the first question, you should use labels
not at
. Read ?axis
.
For the second, you can call axis
or Axis
twice on the same axis, but using rug
is easier. It is a wrapper function for Axis
. For example, you can do:
plot(0:10, 0:10, axes = FALSE) ## `axes` is an argument to `plot.default`
axis(1, at = 0:10, labels = c("AL",1,2,3,4,5,6,7,8,9,"BL"))
rug(x = 0:9 + 0.5, ticksize = -0.01, side = 1)
axis(2, at = 0:10, labels = c("CL",1,2,3,4,5,6,7,8,9,"DL"))
rug(x = 0:9 + 0.5, ticksize = -0.01, side = 2)
You can see how rug
works in its source code:
Axis(side = side, at = x, labels = FALSE, lwd = 0, lwd.ticks = lwd,
col.ticks = col, tck = ticksize, ...)
Read ?par
for how tck
works. The default tck
for an axis is -0.02, so if you want a smaller one for "minor axis", set it to half. Here, the sign means direction. Positive values give ticks pointing inside the plot, while negative ones give ticks pointing outside the plot.
For the minor ticks, you could use the minor.tick
function from the hmisc
package.
minor.tick(nx=2, ny=2, tick.ratio=0.5, x.args = list(), y.args = list())
https://www.rdocumentation.org/packages/Hmisc/versions/4.1-1/topics/minor.tick
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