[R] A beginner's problems with plotting
Morten Sickel
Morten.Sickel at nrpa.no
Fri Dec 13 11:40:04 CET 2002
-----Original Message-----
Jeremy Z Butler wrote:
>Hi,
>How would I go about plotting all 8 columns of a data.frame on a simple
line
>graph. i.e. eight lines and sets of points, differentiated by line pattern
or
>colour)?
>
>An what further arguments would I need to invoke a log scale on the y-axis
of
>that same plot (normal x-axis)?
For example (a snippet from something I have been working on the last couple
of days)
plot(Nucs$Year,Nucs[[2]],type='b',xlim=c(first,last),pch=2,col=2,
ylim=c(min,max),xlab='',ylab='Releases, GBq/year',log=logax)
for (i in c(3:length(Nucs))){
lines(Nucs$Year,Nucs[[i]],col=i)
points(Nucs$Year,Nucs[[i]],col=i,pch=i)
}
Nucs is my data frame, Year is the X variable. I am setting up the plot and
plotting the first series with the plot command, Earlier in my script I have
calculated the min,max,first and last values, set them manually if you know
them. If the variable logax is set to 'y' (or maybe also 'Y') then the y
axis is plottet logaritmic.
By the way, you might end up with one of the palette colors being white,
what you probably do not want... if that happens, run a
palette(c('red','blue','green','yellow','orange','black','brown','violet','p
urple'))
before doing the plot.
(I am by no means an R-expert, somebody might have a better solution, but
this works fine for me.)
Morten
--
Morten Sickel
Norwegian Radiation Protection Authority
http://www.nrpa.no
More information about the R-help
mailing list