Lattice and ggplot graphics, side by side

3 Min Read

One of the confusing things about R for newcomers is the graphics system. Or rather, systems: there are three major ways of creating a graph in R. There’s the base graphics system, which was adopted from S and has been in R from the beginning, and is documented in the Introduction to R manual. But all the cool R programmers these days use one of the newfangled modern systems: either lattice or ggplot2 (both of which are built on the “grid” graphics subsystem).

I’m often asked which of these are better to use, and it’s a hard question to answer. Lattice is probably easier to learn, but once you get over the learning curve ggplot2 has a lot of elegance and power.

To help you decide, the awesome blog Learning R is working through Deepayan Sarkar’s book Lattice: Multivariate Graphics with R and is reproducing the graphics therein using ggplot2. This side-by-side comparison of the same graph done in the two packages is a great way to get a sense of the similarities and differences between the two methods, and to help decide which package is right for you. Be sure to check out all the parts in this multi-part series.

Learning R: ggplot2 Version of Figures in “Lattice: Multivariate


One of the confusing things about R for newcomers is the graphics system. Or rather, systems: there are three major ways of creating a graph in R. There’s the base graphics system, which was adopted from S and has been in R from the beginning, and is documented in the Introduction to R manual. But all the cool R programmers these days use one of the newfangled modern systems: either lattice or ggplot2 (both of which are built on the “grid” graphics subsystem).

I’m often asked which of these are better to use, and it’s a hard question to answer. Lattice is probably easier to learn, but once you get over the learning curve ggplot2 has a lot of elegance and power.

To help you decide, the awesome blog Learning R is working through Deepayan Sarkar’s book Lattice: Multivariate Graphics with R and is reproducing the graphics therein using ggplot2. This side-by-side comparison of the same graph done in the two packages is a great way to get a sense of the similarities and differences between the two methods, and to help decide which package is right for you. Be sure to check out all the parts in this multi-part series.

Learning R: ggplot2 Version of Figures in “Lattice: Multivariate Data Visualization with R” (Part 1) (Part 2) (Part 3)

Link to original post

TAGGED:
Share This Article
Exit mobile version