[R] Plotting Hints - how to add minor tics on axes

Gavin Simpson gavin.simpson at ucl.ac.uk
Wed Aug 12 22:59:49 CEST 2009

On Wed, 2009-08-12 at 11:51 -0700, Jason Rupert wrote:
> Using the standard plotting routine in R, i.e. no special packages, is
> there a way to add in minor tics to the axes?  
> Also, is there a way to make sure the major axes labels are at the
> origin?  When I'm looking at a plot, the major axes labels are
> present, but it looks like they start a bit away from the origin on
> the plot.  
> Thanks again for any info and feedback.

This combines both aspects:

## read ?par and parameters xaxs and yaxs
plot(1:10, xaxs = "i", yaxs = "i")
## notice the above means that the point at 1,1 is obscured

## now add a second axis to the bottom (side 1) with ticks at the 
## specified locations, and shorter tick marks.
## we also suppress the tick labels.
axis(side = 1, at = seq(0, 10, by = 0.1),
     labels = FALSE, tcl = -0.2)

See ?axis for more details on that one.



 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk

More information about the R-help mailing list