Hello, How would I make the default behaviour of my plots produce output such as the following (i.e. tick marks inside on all axes, labels only on two (arbitrary?) sides) without needing the five additional commands each time? plot(1:10, axes=FALSE) axis(1, tcl=0.5) axis(2, tcl=0.5) axis(3, tcl=0.5, labels=FALSE) axis(4, tcl=0.5, labels=FALSE) box() Thanx, DaveT. ************************************* Silviculture Data Analyst Ontario Forest Research Institute Ontario Ministry of Natural Resources david.john.thompson at ontario.ca http://ofri.mnr.gov.on.ca
> How would I make the default behaviour of my plots produce output such > as the following (i.e. tick marks inside on all axes, labels only on two > (arbitrary?) sides) without needing the five additional commands each > time? > > plot(1:10, axes=FALSE) > axis(1, tcl=0.5) > axis(2, tcl=0.5) > axis(3, tcl=0.5, labels=FALSE) > axis(4, tcl=0.5, labels=FALSE) > box()Use a custom plotting function, e.g. myplot <- function(..., sidesforlabels) { #sidesforlabels should be a numeric vector containing the sides that you want labels on plot(..., axes=FALSE) par(tcl=0.5) for(i in 1:4) { axis(i, labels=i %in% sidesforlabels) } box() } myplot(1:10, sidesforlabels=1:2) Regards, Richie. Mathematical Sciences Unit HSL ------------------------------------------------------------------------ ATTENTION: This message contains privileged and confidential inform...{{dropped:20}}
On Wed, Apr 9, 2008 at 10:12 AM, Thompson, David (MNR) <David.John.Thompson at ontario.ca> wrote:> Hello, > > How would I make the default behaviour of my plots produce output such > as the following (i.e. tick marks inside on all axes, labels only on two > (arbitrary?) sides) without needing the five additional commands each > time?It's generally not a very good idea to put the tick marks inside the plot (as e.g. matlab does) because sometimes your data and tick marks will overlap - not good! Hadley -- http://had.co.nz/
This may be a bit simple minded but why not change those commmands into a single function something like this and run it rather than the actual plot command? myfunction <- function(a) { plot(a, axes=FALSE) axis(1, tcl=0.5) axis(2, tcl=0.5) axis(3, tcl=0.5, labels=FALSE) axis(4, tcl=0.5, labels=FALSE) box() } --- "Thompson, David (MNR)" <David.John.Thompson at ontario.ca> wrote:> Hello, > > How would I make the default behaviour of my plots > produce output such > as the following (i.e. tick marks inside on all > axes, labels only on two > (arbitrary?) sides) without needing the five > additional commands each > time? > > plot(1:10, axes=FALSE) > axis(1, tcl=0.5) > axis(2, tcl=0.5) > axis(3, tcl=0.5, labels=FALSE) > axis(4, tcl=0.5, labels=FALSE) > box() > > Thanx, DaveT. > ************************************* > Silviculture Data Analyst > Ontario Forest Research Institute > Ontario Ministry of Natural Resources > david.john.thompson at ontario.ca > http://ofri.mnr.gov.on.ca > > ______________________________________________ > 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. >__________________________________________________________________ [[elided Yahoo spam]]