![]() In these cases, ‘split.screen’ can be very useful. Some panel orientations are too difficult to set up using ‘layout’. Using split.screen for complicated layouts With(cowsub, boxplot(SLA ~ species, yaxt='n')) ![]() With(cowsub, boxplot(folmass ~ species, yaxt='n')) With(cowsub, boxplot(height ~ species, yaxt='n')) # three plots on right (with reduced margins on left and no labels on y-axis) With(cowsub, plot(SLA ~ DBH, col=species, pch=16)) With(cowsub, plot(folmass ~ DBH, col=species, pch=16)) # specify layout using a matrix (note change to 'byrow=F') We can also specify different panel dimensions using the widths and heights arguments for the layout function. With(cowsub, boxplot(SLA ~ species, ylab='SLA')) With(cowsub, plot(folmass ~ age, col=species, pch=16)) Legend('bottomright', legend=levels(cowsub$species), pch=16, col=palette(), bty='n') With(cowsub, plot(height ~ DBH, col=species, pch=16)) # numbers in the matrix elements refer to plot numbers in that section For example, lets look at an example with two rows of plots but with unequal numbers of plots on each row. We can define more complicated layouts using the layout function. Labs(x="Height (m)", y="Total foliage mass (kg)") Ggplot(cowsub, aes(x=height, y=folmass)) + # produce plots, using facet_wrap to separate plots by species This can be done easily using functions in the ggplot2 library. First set up a vector of colours, then index the vector in the plot statement.įor plots such as these, it would be nicer to only have consistent axes and one title on each of the x- and y-axes. Try this yourself: In the above example, use a different colour for each species. Legend('topleft', names(coweeta.spl), bty='n') With(coweeta.spl], plot(folmass ~ height)) # also modify margins so plots are not compressed # set up graphics window with three rows and two columns # take a subset of the speciesĬowsub <- droplevels(subset(coweeta, species %in% c("acru","bele","caov","qupr")))Ĭoweeta.spl <- split(cowsub, cowsub$species) There are multiple ways to set up a multi-panel plot, the simplest of which is to use the ‘mfrow’ (or ‘mfcol’) argument with the ‘par’ function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |