[R] Plotting one or more series on the same graphs

gianpaolo.romeo@nectarine.it gianpaolo.romeo at nectarine.it
Mon Nov 21 11:12:23 CET 2005


Hi, I'm from Italy (sorry for my english...). I've two questions about
the plot function.
I've to create a simple graph for the data set "n_species":


species=sqlQuery(dati, "select count(distinct species), season from
captures_complete_r group by species, season")
n_species=tapply(species$count, species$season, sum)
n_species=data.frame(n_species)
n_species
       n_species
autumn        10
spring         7
summer         7
winter         7


The problem is that, if I use "plot(n_species)", I can't put the seasons
on the x-axis, and so the values on that axes appear as numbers.
I've tried to remove the axis and then I've add with the script:

plot(n_species, type="l", main="Species trend", xlab="Season",  
ylab="Number of species",ylim=c(3,10), col=1, axes=FALSE)
legend("topright", c("Species captured"), col = c(1), lty=c(1))
axis(1,  1:4, c("autumn", "spring", "summer", "winter") )
axis(2, 1:11)


and it seems to work, but when I have decimal value on the y-axis, the
script


plot(k$simp_seas, ylim=c(min(k), max(k)), type="l",main="Index trend", 
xlab="Season", ylab="Index value", axes=FALSE)
points(k$shan_seas, col="red", type="l")
leg.txt=c("Simpson's index", "Shannon's index")
legend("topleft", leg.txt, col=c(1,2), lty=c(1,1))
axis(1,  1:4, c("autumn", "spring", "summer", "winter") )
axis(2, 1:11)

doesn't put decimal value, but jut a "1" in the middle of the vertical
axis.
How can make a correct graphs?

Thanks, Gianpaolo.




More information about the R-help mailing list