## plot of organic C depth functions in 5 profiles
eplot(example, 'Corg', col='black', type='b', main='Example',
xlab='Organic C (percent)', ylab='Depth')
## different colors according to different soil profiles
eplot(example, 'Corg', type='b', main='Example',
xlab='Organic C (%)', ylab='Depth', groups=example$Profile,
panel=1, col=palette()[1:4])
## an example to add a legend with trellis (lattice) commands
trellis.focus("toplevel") ## has coordinate system [0,1] x [0,1]
panel.text(0.65, 0.63, "Site", cex = 0.8, font = 2, pos=4)
panel.text(0.65, 0.59, "P1", cex = 0.8, pos=4)
panel.text(0.65, 0.56, "SG2", cex = 0.8, pos=4, col=palette()[2])
panel.text(0.65, 0.53, "SG5", cex = 0.8, pos=4, col=palette()[3])
panel.text(0.65, 0.50, "SG7", cex = 0.8, pos=4, col=palette()[4])
trellis.unfocus()
Run the code above in your browser using DataLab