Thanks! It worked for me. ?matplot(for_jhon$ID, for_jhon[,2:73], type='l') Any I dea on how I can label multiple-line plot based on column names? Thanks for your help John On Tue, Jul 19, 2016 at 8:46 PM, Greg Snow <538280 at gmail.com> wrote:> Most attachments get stripped off, so your data did not make it through. > > But try: > > ?? > matplot(for_jhon$ID, for_jhon[,2:73], type='l') > > > On Tue, Jul 19, 2016 at 12:24 PM, John Wasige <johnwasige at gmail.com> > wrote: > > Dear all, > > > > This is to kindly request for your help. I would like to plot my data. > > > > The R script below gives some plot that is not clear. How can I get a > clear > > multiple-line plot. The data is attached herewith. > > > > ##R Script > > for_jhon = read.csv("C:/LVM_share/for_ jhon.csv", header=TRUE, sep=";") > > matplot(for_jhon$ID, cbind(for_jhon[,2:73])) > > > > Thanks for your help > > > > John > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > > > > -- > Gregory (Greg) L. Snow Ph.D. > 538280 at gmail.com >-- John Wasige "There are no REGRATES in LIFE, just lessons (Jennifer Aniston)? [[alternative HTML version deleted]]
with 72 lines to label it will be crowded whatever you do. Here is one option (though I am showing with fewer lines): x <- sapply(1:15, function(i) cumsum(rnorm(100))) par(mar=c(5,4,4,3)+0.1) matplot(1:100, x, type='l', lty=1) mtext(LETTERS[1:15], side=4, at=x[100,], las=1, line=1) One way to spread out the labels is: library(TeachingDemos) new.y <- spread.labs(x[100,], mindiff = 1.2*strheight('A'), min=min(x), max=max(x)) mtext(LETTERS[1:15], side=4, at=new.y, las=1, line=2) There is also another label spreading function in the plotrix package and another option for finding space in a plot for labeling lines in either the rms or Hmisc package. There are probably other packages with tools available now as well, but those are the ones that I am familiar with. On Tue, Jul 19, 2016 at 1:36 PM, John Wasige <johnwasige at gmail.com> wrote:> Thanks! It worked for me. > matplot(for_jhon$ID, for_jhon[,2:73], type='l') > > Any I dea on how I can label multiple-line plot based on column names? > > Thanks for your help > > John > > On Tue, Jul 19, 2016 at 8:46 PM, Greg Snow <538280 at gmail.com> wrote: >> >> Most attachments get stripped off, so your data did not make it through. >> >> But try: >> >> matplot(for_jhon$ID, for_jhon[,2:73], type='l') >> >> >> On Tue, Jul 19, 2016 at 12:24 PM, John Wasige <johnwasige at gmail.com> >> wrote: >> > Dear all, >> > >> > This is to kindly request for your help. I would like to plot my data. >> > >> > The R script below gives some plot that is not clear. How can I get a >> > clear >> > multiple-line plot. The data is attached herewith. >> > >> > ##R Script >> > for_jhon = read.csv("C:/LVM_share/for_ jhon.csv", header=TRUE, sep=";") >> > matplot(for_jhon$ID, cbind(for_jhon[,2:73])) >> > >> > Thanks for your help >> > >> > John >> > ______________________________________________ >> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> > 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. >> >> >> >> -- >> Gregory (Greg) L. Snow Ph.D. >> 538280 at gmail.com > > > > > -- > John Wasige > "There are no REGRATES in LIFE, just lessons (Jennifer Aniston)?-- Gregory (Greg) L. Snow Ph.D. 538280 at gmail.com
Thanks so much Best Rgds John On Tue, Jul 19, 2016 at 9:56 PM, Greg Snow <538280 at gmail.com> wrote:> with 72 lines to label it will be crowded whatever you do. > > Here is one option (though I am showing with fewer lines): > > x <- sapply(1:15, function(i) cumsum(rnorm(100))) > par(mar=c(5,4,4,3)+0.1) > matplot(1:100, x, type='l', lty=1) > mtext(LETTERS[1:15], side=4, at=x[100,], las=1, line=1) > > One way to spread out the labels is: > > library(TeachingDemos) > new.y <- spread.labs(x[100,], mindiff = 1.2*strheight('A'), > min=min(x), max=max(x)) > mtext(LETTERS[1:15], side=4, at=new.y, las=1, line=2) > > > There is also another label spreading function in the plotrix package > and another option for finding space in a plot for labeling lines in > either the rms or Hmisc package. There are probably other packages > with tools available now as well, but those are the ones that I am > familiar with. > > > > On Tue, Jul 19, 2016 at 1:36 PM, John Wasige <johnwasige at gmail.com> wrote: > > Thanks! It worked for me. > > matplot(for_jhon$ID, for_jhon[,2:73], type='l') > > > > Any I dea on how I can label multiple-line plot based on column names? > > > > Thanks for your help > > > > John > > > > On Tue, Jul 19, 2016 at 8:46 PM, Greg Snow <538280 at gmail.com> wrote: > >> > >> Most attachments get stripped off, so your data did not make it through. > >> > >> But try: > >> > >> matplot(for_jhon$ID, for_jhon[,2:73], type='l') > >> > >> > >> On Tue, Jul 19, 2016 at 12:24 PM, John Wasige <johnwasige at gmail.com> > >> wrote: > >> > Dear all, > >> > > >> > This is to kindly request for your help. I would like to plot my data. > >> > > >> > The R script below gives some plot that is not clear. How can I get a > >> > clear > >> > multiple-line plot. The data is attached herewith. > >> > > >> > ##R Script > >> > for_jhon = read.csv("C:/LVM_share/for_ jhon.csv", header=TRUE, > sep=";") > >> > matplot(for_jhon$ID, cbind(for_jhon[,2:73])) > >> > > >> > Thanks for your help > >> > > >> > John > >> > ______________________________________________ > >> > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > >> > 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. > >> > >> > >> > >> -- > >> Gregory (Greg) L. Snow Ph.D. > >> 538280 at gmail.com > > > > > > > > > > -- > > John Wasige > > "There are no REGRATES in LIFE, just lessons (Jennifer Aniston)? > > > > -- > Gregory (Greg) L. Snow Ph.D. > 538280 at gmail.com >-- John Wasige "There are no REGRATES in LIFE, just lessons (Jennifer Aniston)? [[alternative HTML version deleted]]