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]]
does lty not work? please read the posting guide. On Tue, Jun 10, 2008 at 12:13 PM, Tariq Perwez <tariq.perwez@gmail.com> wrote:> 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@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. >-- Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis [[alternative HTML version deleted]]
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. >
Jorge Ivan Velez
2008-Jun-10 16:28 UTC
[R] Plotting multiple continuous lines with symbols
Dear Tariq, A good starting point would be ?matplot. Also, you can try this: set.seed(123) X=cbind(1:10,matrix(rnorm(10*5),ncol=5)) matplot(X[,1],X[,2:5],type='o',lty=1,col=1,pch=1:5,xlab="Variable X",ylab="Outcome") and the add your any text you want around. HTH, Jorge On Tue, Jun 10, 2008 at 12:13 PM, Tariq Perwez <tariq.perwez@gmail.com> wrote:> 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@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. >[[alternative HTML version deleted]]