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.
You can use the axis function to add tick marks and labels at specified positions (including whatever origin you want to use). If you add shorter tick marks without labels, then they are minor ticks (usually you will suppress the default axes using axes=FALSE or xaxt/yaxt='n', then use the axis function to add in your own custom ticks and labels (call once for major ticks, a second time for minor). Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Jason Rupert > Sent: Wednesday, August 12, 2009 12:51 PM > To: R-help at r-project.org > Subject: [R] Plotting Hints - how to add minor tics on axes > > 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. > > ______________________________________________ > 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.
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. HTH G -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% 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 %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%