BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar


May 28, 2014

Combining city & state information on map in Graph Builder - Part 1

Showing a map within Graph Builder in JMP has become a popular way to visualize data. This is partly because you can color the geographic area of interest based on a variable in the data table (Figure 1).


Figure 1

Or you can plot cities as points if you have latitude and longitude information (Figure 2).


Figure 2

But what if you want to combine both?

A customer wanted to do exactly that. This JMP user was trying to show specific cities with states of interest while coloring those states on a particular property that was in a data table. On top of that, the JMP user wanted to be able to hover over the city to display its name and additional city information.

No problem! I’ll show you how. In my example, I'll use city pollution and population data found in data set (found in the Sample Data under Help in JMP), and I'll join it with some state-level crime data (total crime, in this case). I'll use the crime data from data set, which is also found in the Sample Data directory in JMP. The goal here is to show crime rate for each state in a given year and be able to see pollution levels for a given city in that state. The purpose is to explore a potential link between the two without plotting too much information.

The desired graph looks like this (Figure 3):


Figure 3

To create the desired graph, I will need to overlay the cities in their geographic location as points on top of the states, while at the same time making sure that only the states are colored. To make the graph, you would do the following, in order:

  1. Drag Latitude and Longitude to the Y and X areas, respectively.
  2. Drag State to the Map Shape Zone.
  3. Remove Smoother Graph Type by clicking its icon on the top Graph Type Toolbar.
  4. Drag State Total Crime Rate to the Color Zone.
  5. Drag and drop Points Graph Type onto the plot.
  6. Go to the Points section (see Figure 4). Find the Variables subsection, click on the “…” button and uncheck Color and Map Shape (see Figure 4). This option is needed to remove the coloring from the points and to allow them to center on their geographic coordinates instead of being centered on the state.
  7. CJK_Blog_07-2014_step-6_Figure-4

    Figure 4

    For presentation purposes, I need to remove the axes (they do not add any information here) and change the color of the gradient representing total crime rates to something that is sequential instead of divergent (so I display the information in a more informative way). Right-clicking on each axis and removing tick marks and label gets rid of most of the axis. Next, I right-click on the center of the graph and then go to Graph>Border to uncheck the left and bottom border. If Latitude and Longitude still appear, I can select the text and delete it. I now have the graph/map depicted in Figure 3, but I am not done yet.

    I wanted to be able to hover over each city and see the city name and additional meta-data/information found in the other columns. To make this happen, I:

    1. Select the columns of interest on the data table.
    2. Right-click on one of the column headers and choose Label/Unlabel (see Figure 5).
    3. CJK_Blog_07-2014_label-table_Figure-5

      Figure 5

      When I hover the cursor over the city of interest, I get the information I want. I now have the desired output and behavior, as in Figure 3.

      Now I can explore each city of interest without having to plot all the information on the same graph!

      However, what if I wanted to show more information about the cities on the map? How would I show something like population size for each city and one of the pollution columns in the map without having to hover over each city? Stay tuned – the answer to these questions will come in a follow-up blog post.