Print(bxp, vp = define_region(row = 2, col = 1)) ![]() Print(sp, vp = define_region(row = 1, col = 1:2)) # Span over two columns # A helper function to define a region on the layout PushViewport(viewport(layout = grid.layout(nrow = 3, ncol = 2))) Define a grid viewport : a rectangular region on a graphics device. ![]() Create a layout 2X2 - number of columns = 2 number of rows = 2.Move to a new page on a grid device using the function grid.newpage().The different steps can be summarized as follow : The function print() is used to place plots in a specified region. It provides also the helper function viewport() to define a region or a viewport on the layout. ![]() The grid R package can be used to create a complex layout with the help of the function grid.layout(). grid.arrange(bp, # bar plot spaning two columns The first row is all 1s, that’s where the first plot lives, spanning the two columns the second row contains plots 2 and 3 each occupying one column. In the R code below layout_matrix is a 2x2 matrix (2 columns and 2 rows). It’s also possible to use the argument layout_matrix in the grid.arrange() function, to create a complex layout. Grid.arrange(sp, # First row with one plot spaning over 2 columnsĪrrangeGrob(bxp, dp, ncol = 2), # Second row with 2 plots in 2 different columns
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |