# [R] Tick marks for abline

Ross Ihaka ihaka at stat.auckland.ac.nz
Thu Oct 26 22:11:48 CEST 2000

```On Thu, Oct 26, 2000 at 11:29:18AM -0500, Erin Hodgess wrote:

> I am drawing graphs for a College Algebra class. I would like to have
> the x and y axes, along with the lines that I am plotting.  So I leave
> off the axes, and use xlim and ylim.  Then I add my abline(v=0).
>
> However, I would like to have tick marks on the abline.  How would I do

Here is an example of drawing a cubic with axes in the middle of the
plot.

#  Draw the basic curve (limits were established by trial and error).
#  The axes are turned off blank axis labels used.

curve(x * (2 * x - 3) * (2 *  x + 3), from = -1.85, to = 1.85,
xlim = c(-2, 2), ylim = c(-10, 10),
axes = FALSE, xlab = "", ylab = "")

#  Draw the axes at the specified positions (crossing at (0, 0)).
#  The ticks positions are specified (those at (0,0) are omitted).
#  Note the use of las=1 to produce horizontal tick labels on the
#  vertical axis.

axis(1, pos = 0, at = c(-2, -1, 1, 2))
axis(2, pos = 0, at = c(-10, -5, 5, 10), las = 1)

#  Use the mathematical annotation facility to label the plot.

title(main = expression(italic(y==x * (2 * x - 3) * (2 * x + 3))))

Ross
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```