Dear R People: 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 that, please? Thanks in advance! Sincerely, Erin M. Hodgess, Ph.D. Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown One Main Street Houston, TX 77002 e-mail: hodgess at uhddx01.dt.uh.edu -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Erin Hodgess <hodgess at uhddx01.dt.uh.edu> writes:> Dear R People: > > > 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 > that, please?Here's a starting point: plot(0,0) axis(1, pos=0) axis(2, pos=0) You probably want to leave off the markings at 0.0 there, but check the help for axis() for things you can do. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I'm a little bit puzzled by your requirements. If you want just x and y axes and not the top and right sides of the box plotted you could try par(bty="l") [which I actually prefer as my default setting]. Alternately, you can use axis() with side=1 or side=2 to draw the axis after doing the main plot (and control ticks, labels, style, etc.). If neither of these do what you want you could (masochistically) try figuring out exactly where you want all your ticks and use segments() to draw them. Or, if what you need to do is suppress labels on the axes, you can use ann=FALSE in plot (?plot.default). You can also look at box(), par(bty), and par(xaxs), par(yaxs) for information about where and how the axes are plotted. ?par contains an enormous amount of information, but it's worth going through every so often for ideas. Ben Bolker On Thu, 26 Oct 2000, Erin Hodgess wrote:> Dear R People: > > > 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 > that, please? > > Thanks in advance! > > Sincerely, > Erin M. Hodgess, Ph.D. > Associate Professor > Department of Computer and Mathematical Sciences > University of Houston - Downtown > One Main Street > Houston, TX 77002 > e-mail: hodgess at uhddx01.dt.uh.edu > > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ > >-- 318 Carr Hall bolker at zoo.ufl.edu Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker Box 118525 (ph) 352-392-5697 Gainesville, FL 32611-8525 (fax) 352-392-3704 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 > that, please?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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._