[R] Plotting multiple continuous lines with symbols

Greg Snow Greg.Snow at imail.org
Tue Jun 10 18:27:46 CEST 2008


In your plot and lines function call you specify type="b" which says to use "b"oth lines and points with gaps in the lines around the points.  If you change that to type="o" then it will "o"verplot the points and lines (no gaps).

The different types are documented in ?plot.default.

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
(801) 408-8111



> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of Tariq Perwez
> Sent: Tuesday, June 10, 2008 10:14 AM
> To: r-help at r-project.org
> Subject: [R] Plotting multiple continuous lines with symbols
>
> Hi,
> I am trying to plot multiple lines on one plot such that all
> lines are of the same color (black) and continuous. I need to
> distinguish these multiple plots from each other by using
> different symbols (I am using pch=). However, all my lines
> are broken on both sides of the symbols. This unfortunate (and
> unsightly) behavior seems to be the default. In my search of
> the help archives for R over several days, I have not been
> able to solve this problem. I would appreciate any help and
> suggestions. My code for the plot is below (minus the data):
>
> exa1.1 <- read.table("multcol.txt", header=T, sep='    ')# Total of 4
> columns; first one to be on x-axis
> attach(exa1.1)
> names(exa1.1)
> exa1.1
>
>
> plot(exa1.1$Year, exa1.1$EM, ylim=range(exa1.1[,-1]), type =
> 'b' ,pch=16, main = ""), las=1, cex.main=1.75,lab
> =c(12,8,10), ylab="", xlab="", )
> lines(exa1.1$Year,exa1.1$IM,type='b', pch=1)
> lines(exa1.1$Year,exa1.1$BM,type='b', pch=17) mtext(side = 2,
> text = "Klett units", line = 3.5, cex=1.2) mtext(side = 1,
> text = expression(Time~at~37*degree*C~(minutes)), line =
> 2.75,cex=1.2)
>
>
> Regards,
>
> Tariq
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list