It takes a little trial-and-error to hit on margins that produce the desired spacing. Yikes! What a mess! We can use the mai argument to the par( ) function to specify the margin (in inches) of each panel in the figure. Plot(Sepal.Length~Sepal.Width, data=iris, subset=(Species="setosa"), xlab="Sepal Width", ylab="Sepal Length", xlim=c(min.width,max.width), ylim=c(min.length,max.length)) Plot(Sepal.Length~Sepal.Width, data=iris, subset=(Species="versicolor"), xlab="Sepal Width", ylab="Sepal Length", xlim=c(min.width,max.width), ylim=c(min.length,max.length)) Plot(Sepal.Length~Sepal.Width, data=iris, subset=(Species="virginica"), xlab="Sepal Width", ylab="Sepal Length", xlim=c(min.width,max.width), ylim=c(min.length,max.length)) I am writing to the PNG graphics device to post the figures online using a different graphics device (e.g., TIFF) might require adjustments to the arguments that control the panel spacing. The empty panel can be placed in any of the 4 positions, but it is redundant to use plot.new( ) for the bottom right panel because mfrow fills the graphics device by row, moving left to right along the row. An empty panel is created by calling plot.new( ). The next block of code plots 3 panels in a 2×2 arrangement with mostly default options. To plot all the data on the same scale, we need to extract the max and min values of the variables that we are plotting. In this case, the data would be more effectively plotted in a single panel with different colors or symbols for each species, but with larger data sets the different colors/symbols can create a jumbled mess and multi-panel figures illustrate patterns in the data more clearly. The data set includes flower measurements for 3 iris species. Below I will walk through how to adjust the spacing of the panels when using mfrow.įor this example, we will use Edgar Anderson’s iris data, which is distributed with R. The figures in that post were ugly because they used the default panel spacing associated with the mfrow argument of the par( ) function. In a previous post, I showed how to keep text and symbols at the same size across figures that have different numbers of panels.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |