min.width min (irisSepal.Width) min.length min (irisSepal.Length) max.width max (irisSepal.Width) max.length max (irisSepal. For example, par (marc (5.1,4.1,4.1,2.1) sets the bottom, left, top and right margins respectively of the plot region in number of lines of text. The endgame: create a multi-panel plot entirely via code Multi-panel plots can provide an elegant way to tell a visual story that is driven by narrative. # Margins area par( oma= c( 3, 3, 3, 3)) # all sides have 3 lines of space par( mar= c( 5, 4, 4, 2) + 0.1) # Plot plot( 0 : 10, 0 : 10, type= "n", xlab= "X", ylab= "Y") # type="n" hides the points # Place text in the plot and color everything plot-related red text( 5, 5, "Plot", col= "red", cex= 2) box( col= "red") # Place text in the margins and label the margins, all in forestgreen mtext( "Margins", side= 3, line= 2, cex= 2, col= "forestgreen") mtext( "par(mar=c(b,l,t,r))", side= 3, line= 1, cex= 1, col= "forestgreen") mtext( "Line 0", side= 3, line= 0, adj= 1.0, cex= 1, col= "forestgreen") mtext( "Line 1", side= 3, line= 1, adj= 1.0, cex= 1, col= "forestgreen") mtext( "Line 2", side= 3, line= 2, adj= 1.0, cex= 1, col= "forestgreen") mtext( "Line 3", side= 3, line= 3, adj= 1.0, cex= 1, col= "forestgreen") box( "figure", col= "forestgreen") # Label the outer margin area and color it blue # Note the 'outer=TRUE' command moves us from the figure margins to the outer margins. We can put multiple graphs in a single plot by setting some graphical parameters with the help of par() function. 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. It is fairly straightforward to set the margins of a graph in R by calling the par () function with the mar (for margin) argument.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |