[R] Drawing multiple line plots
Chuck Cleland
ccleland at optonline.net
Wed Oct 20 14:45:19 CEST 2004
?matplot
For example:
myFrame <- data.frame(lowest = c(0.107, 0.091, 0.126),
second = c(0.115, 0.107, 0.103),
third = c(0.123, 0.115, 0.126),
fourth = c(0.115, 0.142, 0.129),
highest = c(0.166, 0.179, 0.142),
sig = c(0.000, 0.000, 0.031))
par(las=1)
matplot(t(myFrame[,-6]), type="l", xaxt="n", ylab="INMET",
col=c("black", "red", "blue"), lty=c(1,1,1))
axis(side=1, at=1:5, names(myFrame)[1:5])
legend(1, 0.18, c("INAS", "MMA", "DMA"), lty=c(1,1,1),
col=c("black", "red", "blue"))
Arin Basu wrote:
> Hi All:
>
> Greetings, and best wishes from the festive times here at Kolkata, India -- the time of Durga Puja celebrations.
>
> I seek your advice as I try plotting lines for my data. The problem:
>
> I have created a dataframe that looks like this (name: myFrame):
>
> lowest second third fourth highest significance
> INAS 0.107 0.115 0.123 0.115 0.166 0.000
> MMA 0.091 0.107 0.115 0.142 0.179 0.000
> DMA 0.126 0.103 0.126 0.129 0.142 0.031
>
> The numbers in the dataframe indicate values of a continuous variable INMET (indicating ratio of inorganic arsenic vesus methylated arsenic species) for the respective quintiles of variables INAS, MMA, and DMA; "lowest" through "highest" indicate quintile levels of INAS,
> MMA, and DMA. INAS, MMA, and DMA are discrete ordinal variables (factors, each variable has following levels: lowest, ..., highest). Significance indicates significance levels.
>
>>From this dataframe, I want to plot INAS, MMA, and DMA (x-axis : levels "lowest" through "highest", y-axis: values of INMET) as separate lineplots in the same graphic window. I can individually plot lines for INAS,MMA, and DMA; however, I want the three lines to appear in the same graph (say in different colors).
>
> Searching the archives and the documentation, I got to interaction.plot(), but this is not what I want.
>
> I can export the dataframe to a spreadsheet program and can draw such a graph (one graph with multiple lines, one for INAS, one for MMA, and one for DMA), but would prefer to do it in R.
>
> I looked for, but could not locate how to do that in either the R documentation, or the archives of mailing list postings. I suspect I am missing something very obvious; if there is a solution that I was inept to look up in the documentation or archives, I duly apologize.
>
> Would greatly appreciate your advice.
>
> Kind regards,
> Arin Basu
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894
More information about the R-help
mailing list