Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Graph Builder gets a lot of attention in the JMP Blog and from our customers because it is so flexible. People really like to stretch what it can do and create graphs that communicate with their peers in compelling ways.
Recently, a customer asked me whether it was possible to hide the empty groups that would appear in Graph Builder when you have a continuous y and x and then use two variables for Group X (see Figure 1).
To illustrate the point, take a look at a line plot of the “Big Class” data set in JMP Sample Data. To create the graph, we drag height onto the y-axis and weight onto the x-axis. Choose the line icon from the top graph elements menu and then drag in the points icon from the top graph elements menu. We then drag the age column to the Group X zone and then drag the second column, sex, onto the right of the first variable used for the Group X zone (as in Figure 1, below):
Figure 1: Problematic Graph
Here, we see that Male at age 16 and Female at Age 17 have no data. The issue lies in the empty graph that is created for these two groups. It takes up space because of the lack of data. A lot of graph real estate can be wasted in this way if there are several groups that have no data. (Imagine 10 groups with 10 groups in each and having several empty graphs! Yuck, too much white space.) This would make it difficult to show on a screen during a live presentation or in a report outside of JMP (say, in a Word document or a PowerPoint presentation).
The best way to deal with this is to make a new combined grouping column, which will not have the problematic groups. Here’s an example that does that with a transform column (Figure 2). To do this, select the two columns to combine. Then, right-click on them (this is how you access a new feature in JMP 11 that transforms variables) and choose Character>Concatenate with Space.
Figure 2: Transform Columns Option
A new column appears in the Variables panel called “Concatenate [age,sex].” You can now use this new (temporary) column to drag to the Group X zone to remove the unwanted empty graphs (Figure 3).
Figure 3: Desired Graph with Columns Concatenated
This works as long as one of the columns is a character-based variable. If you have two or more continuous columns, then you need to use a different approach. You need to make a new column formatted as character data and apply a formula using the Char and Concat functions within the Character group
Here is an example from the Big Class data set where I recoded M and F to 1 and 0 to represent a numeric continuous column (Figure 4).
Figure 4: Column Formula for 2 Continuous Numeric Columns
The result is a new character-based column that represents the two (or more) columns that you want to display as separate graphs using Group X zone.
In cases with categorical variables (character or numeric) on the x-axis, it is best to use a nested axis, which leaves out empty levels automatically (Figure 5).
Figure 5: Bar Chart of 2 Categorical Variables on X-axis
You can accomplish this by either grabbing the two columns of interest and dropping them onto the x axis zone, or dragging them one at a time. You can position the second one within the first by dragging it on the axis. You can achieve the reverse situation (first within the second) by dragging the second on top of the x axis label of the first.
Regardless of the data types of the columns you want to use for grouping/graphing your data, there is a way to help you show only the graphs you have.