[R] pch and curve plotting

Prof Brian D Ripley ripley at stats.ox.ac.uk
Wed Aug 9 18:09:07 CEST 2000

On Wed, 9 Aug 2000, Margaret Riordan wrote:

> Hi all,
> I'm having two small problems and was wondering if you could help me
> out.
> Problem 1:
> When I use pch to place a symbol onto a plot it seems to place the point
> a little off the exact location. I have read the help file for this
> which says to use "." as the plotting character, which will then produce
> centered points but I am unclear as to how to do this.

pch="."   But we have tried hard to get the symbols in the right
places, so which R version and which graphics device is this?


plot(1:10, 1:10, type="n")
for(i in 1:10) for(j in 1:10) points(i, j, pch = ".")

is correct (to 0.5 pixel) on my system) and so is

for(i in 1:10) for(j in 1:10) points(i, j, pch = 16)

(yes, I do know how to vectorize this!)

> Problem 2: How do I get R to draw a curve through a number of data
> points rather than a straight line. From the description of the
> functions scatter.smooth and loess.smooth, I think they are what I'm
> looking for,
> but when I try to run them in R Version 1.1.0, it returns the following
> error
> Error in sdgraph() : couldn't find function "scatter.smooth"

They are in library modreg. You should not have got help on them in
1.1.0 without doing library(modreg) first.

However, they fit a smooth curve through a scatter plot, not through
the data points themselves (smoothing, not interpolation).
There are many other possibilities, and I would tend to prefer
smooth.spline (also in modreg) as it automatically chooses the 
degree of smoothing.   Then there are regression splines, running
lines smoothers (supsmu), kernel smoothers, ....  V&R3 and
its on-line statistical complements have a catalogue and comparisons.

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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

More information about the R-help mailing list