[R] Plotting extra lines on scatterplot

John Fox jfox at mcmaster.ca
Sat May 2 03:02:18 CEST 2009

Dear Tony,

>From ?scatterplot:

"reset.par: if TRUE then plotting parameters are reset to their previous
values when scatterplot exits; if FALSE then the mar and mfcol parameters
are altered for the current plotting device. Set to FALSE if you want to add
graphical elements (such as lines) to the plot."

I hope this helps,

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> Behalf Of Tony Laidig
> Sent: May-01-09 4:14 PM
> To: r-help at r-project.org
> Subject: [R] Plotting extra lines on scatterplot
> Hello Everyone-
> I'm in the process of slowly learning R and am having a little bit of
> trouble plotting an extra line onto a scatterplot. I'm sure the answer
> is quite simple but I am stumped.
> The code I am using is:
> headways <- read.table("headways.csv", header=TRUE, sep=",",
> na.strings="", dec=".", strip.white=TRUE)
> plot.new()
> scatterplot(dechway~dechr, reg.line=FALSE, smooth=TRUE, labels=F,
> boxplots='y', span=0.5, xlab="Time", ylab="Headway", ylim=c(0,9),
> data=headways)
> lines(headways$dechr, headways$schedule)
> A subset of the dataset I'm working with is at
> http://web.mit.edu/c64/www/headways.csv .
> The extra line, plotted with lines(), should be right at 4, but is
> actually below where it should be. I assume that I'm using the wrong
> function to plot this line, as there are many ways to do it, but have
> not the experience to know which function is appropriate to use with
> scatterplot().
> Thank you for all of your help.
> -Tony
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list