Data Visualization First Steps

Facets for Comparing Group Data Exercise

Anjana Vakil

Anjana Vakil

Software Engineer & Educator
Data Visualization First Steps

Check out a free preview of the full Data Visualization First Steps course

The "Facets for Comparing Group Data Exercise" Lesson is part of the full, Data Visualization First Steps course featured in this preview video. Here's what you'd learn in this lesson:

Students are instructed to arrange the facets horizontally along the x-axis, use the previously used devices data for the facets and use the device type (mobile, tablet, desktop) to create the facets.


Transcript from the "Facets for Comparing Group Data Exercise" Lesson

>> Okay, one more thing to talk about here, which is before we saw that it can be useful to smush groups together, aggregate them using those group transforms. Sometimes it can also be useful to split groups apart. So in this case, we have all of these different dots kind of right on top of each other.

So it kind of starts to get obscured, like, it looks like maybe we have some other blue or red dots in there. We have some kind of red and blue dots mixed in together. It becomes a little bit difficult to see exactly which device categories are where because they're all kind of on top of each other on this one plot.

So as an additional exploration of our data, what we can do is separate out those three device groups, desktop, mobile and tablet to see if there are any hidden details that we can reveal. So what we're gonna do for splitting those apart is using a concept called facets, which we spoke briefly about earlier.

So facets which are also called small multiples in some cases, these are these smaller minicharts that essentially visualize just a subset of the data. And when we put many of those small charts together, those small multiples, we can compare different subsets of the data set that we're interested in.

So in this case, our data set naturally lends itself to these three kinds of nice little subsets, the desktop devices, the mobile devices and the tablets. And so what we're going to do is use plot to tell it with its notion of faceting to split this dot plot up, this type of plot that we have here.

We're gonna tell plot to split it up into three smaller plots, each one, corresponding to one of the device categories. Okay, so the syntax for specifying facets in plots is that when we make our call to that .plot method. In addition to all of our settings for the different scales and the margins and other kinds of layout properties like that.

We can specify a facet object, facet property which then we give as a value an object, which has a couple of main features. So one is that we're gonna tell plot which data we want it to be faceting based on. In this case, it's gonna be the same data that we're using to draw our plot.

There might be cases where you want to split up data in your plot based on some other corresponding data, but in this case it's the same data. And then we want to tell plot which property in the data we want to use as the splitting property and which channel we want to split across.

So for example if I want to split across vertically, if I wanna make vertical facets here that will be the wide channel and then the name of whatever feature I want to split based on. So what we're gonna do in our next exercise is trying to make some faceted plots out of the .plot that we just created.

So I'm just gonna copy this one into here. So you all can copy. I'm copying my solution, but you can copy whatever your solution was into this cell here and then modify it to add facets using this syntax. So it's up to you which way you wanna split things.

You can play around with it and see what feels best. But what we wanna do is use the device type as the faceting feature.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now