
First you initialize the grid, then you pass plotting function to a map method and it will be called on each subplot. The basic usage of the class is very similar to FacetGrid. Using PairGrid can give you a very quick, very high-level summary of interesting relationships in your dataset. In the latter, each plot shows a different relationship (although the upper and lower triangles will have mirrored plots). In the former, each facet shows the same relationship conditioned on different levels of other variables. It’s important to understand the differences between a FacetGrid and a PairGrid. This style of plot is sometimes called a “scatterplot matrix”, as this is the most common way to show each relationship, but PairGrid is not limited to scatterplots. In a PairGrid, each row and column is assigned to a different variable, so the resulting plot shows each pairwise relationship in the dataset. PairGrid also allows you to quickly draw a grid of small subplots using the same plot type to visualize data in each. For example, say we wanted to examine differences between lunch and dinner in the tips dataset: These variables should be categorical or discrete, and then the data at each level of the variable will be used for a facet along that axis.

The class is used by initializing a FacetGrid object with a dataframe and the names of the variables that will form the row, column, or hue dimensions of the grid. The first two have obvious correspondence with the resulting array of axes think of the hue variable as a third dimension along a depth axis, where different levels are plotted with different colors.Įach of relplot(), displot(), catplot(), and lmplot() use this object internally, and they return the object when they are finished so that it can be used for further tweaking. A FacetGrid can be drawn with up to three dimensions: row, col, and hue. The FacetGrid class is useful when you want to visualize the distribution of a variable or the relationship between multiple variables separately within subsets of your dataset.
