[R] abline() plot order

Al Piszcz apiszcz at solarrain.com
Thu Aug 7 20:05:18 CEST 2003


you have been very helpful, thank you, this works fine.




On Thu, 7 Aug
2003, Marc Schwartz wrote:

> Date: Thu, 07 Aug 2003 12:30:52 -0500
> From: Marc Schwartz <MSchwartz at MedAnalytics.com>
> To: Al Piszcz <apiszcz at solarrain.com>
> Cc: r-help at stat.math.ethz.ch
> Subject: Re: [R] abline() plot order
>
> On Thu, 2003-08-07 at 12:01, Al Piszcz wrote:
> > Marc:
> >
> > I am interested in having only 'y' or 'x' axis tick
> > bars light gray across graph.
> >
> > I did not realize there was a barplot2, thank you.
> >
> > I used your second technique (add=TRUE) and it works!
> > Thank you very much for the speed of reply and quality
> > of the options.
> >
> > The plot looks very good with the lines behind the bars!
> >
> >
> >
> >
> > I've been look at par and axTicks, and found everything
> > I need except control of the Y tickmarks, major and minor.
> > It is probably in there I just have not located it.
>
>
> Al,
>
> Your most flexible option on the tick mark locations is to use axis(),
> which allows you to specify the locations. Use 'axes = FALSE' in
> conjunction with barplot().  See ?axis for more information.
>
> Example:
>
> # draw the barplot without axes
> barplot(1:5, axes = FALSE)
>
> # Now draw the 'minor' tick marks as short lines
> # and do not plot any labels
> axis(2, at = seq(0, 5, 0.5), lwd = 1, tck = -0.01,
>      labels = FALSE)
>
> # Now draw the 'major' tick marks with slight longer and thicker
> # lines with labels
> axis(2, at = 0:5, lwd = 2, tck = -0.015)
>
> # Now draw the grid lines at the major tick marks in gray
> # If you want the lines at the 'minor' tick marks
> # use: abline(h = seq(0, 5, 0.5), lty = "solid", col = "gray90")
> # adjust the line type and color as you desire. See ?colors
> abline(h = 0:5, lty = "solid", col = "gray90")
>
> # Now replot the bars so they are over the lines
> par(new = TRUE)
> barplot(1:5, axes = FALSE)
>
> HTH,
>
> Marc
>
>




More information about the R-help mailing list