I’ve wanted to spend some time to learn how to use the grid graphics pattern for a while. A recent assignment at work gave me the opportunity to do so. I found a great tutorial by Zhou and Braun entitled Fun with the R Grid Package. The grid package allows you to build up a visualization from the ground up. By using viewports, the user can define any piece of the canvas in order to build a small visualization. The power of these visualization comes together when many of these smaller visualizations are put together.
Below is a small example of how this works:
I found that this concept could be very powerful when conducted in a loop. I was trying to create a chart of some data that looked a bit like a periodic table. It wanted the most recent number in the center of each square, with the change from last quarter in the upper right hand quarter, and the last four quarter sparkline at the bottom of the chart. Additionally, the columns would be colored based on a rate, with red being a high rate and green being a low rate. An example of this is given below with randomly generated numbers:
The grid package is extremely powerful, especially if you want to tailor a specific visualization for a given problem set.