Assignment 10: Building a dashboard with Tableau¶
You’ve made it to your last assignment of the semester! In this assignment, you’re going to learn how to “put everything together” into the form of an interactive dashboard. Dashboards are applications that may include multiple charts, which in some cases are configured to interact with one another. While there are many ways to build dashboards, including in Python, one of the most popular software applications for these types of visualizations is Tableau.
Tableau, like other software products we’ve discussed this semester, employs a tiered pricing structure. We’ll be working in this assignment with Tableau Public 2021.3, a free version of Tableau. Tableau comes in other flavors; Tableau Desktop is the core commercial version, and Tableau Server is an enterprise version that can be deployed from a company’s server. Tableau Public includes most of the features of the paid versions; the key caveat is that your visualizations must be saved to Tableau’s public cloud and shared publicly; private visualizations are only available in the paid versions.
Tableau Public is installed on the computers in our classroom. If you are working on your own computer, you can install it from https://public.tableau.com/en-us/s/download I’d recommend this for completing the assignment. All you need to provide is your email address to get this done. However, at this point I’d also recommend creating a Tableau Public profile - this will be necessary for the assignment as well. From https://public.tableau.com/s/, click the “SIGN IN” button in the upper right of the screen; next, click the “Create one now for free” link to create a profile. Once you’ve activated your profile, you’ll find an available link to download the Tableau Public application as well.
At the end of our class on geographic data and visualization, we discussed the pros and cons of visualizing data with maps or charts, or vice versa. As a refresher, we compared the following map of primary sector employment by state in Mexico:
With the following
seaborn dot plot:
<img src=”http://walkerke.github.io/geog30323/slides/geographic/img/primarydot2.png” style=”width: 650px”
Certainly, there are advantages and disadvantages to each plot; for example, the map shows geographic clustering (e.g. high values in the south of Mexico), whereas the plot more clearly displays quantitative differences between states. A solution to this could be to include both visualizations in a report (like in a Jupyter Notebook!) to show the data in different ways. However: there are also ways to include both the map and the dot plot in the same graphic - and make the two visuals interact with each other! Creating charts like this is one of Tableau’s strengths - and something you’ll learn how to do in this assignment.
Mapping Mexican states in Tableau¶
To get started, download the data for this assignment from the following link: http://personal.tcu.edu/kylewalker/mexico.csv, and save it somewhere where you’ll know how to find it. Next, launch the Tableau Public application. You should see som Drag and drop your Mexico CSV file onto the application, and Tableau will load it for you. You’ll get a preview of your data as it will appear in Tableau; at this point, you can make some modifications to the columns if you’d like, such as renaming them; however, let’s proceed by clicking “Sheet 1” at the bottom of the screen.
You’ll see the main Tableau application view appear, like the image below.
Your columns on the left hand side of the screen are divided into Dimensions, which refer to the text values in your data, and Measures, which are numeric values. Building charts in Tableau is based on a drag-and-drop interface, in which you will move these column names into the right spots for building a visualization.
As we’re going to make a map first, we need to identify the geographic information in our dataset. Individual states can be identified by their names; Tableau includes a host of built-in geographic outlines that can be matched to values in CSV data like our data on Mexico. Follow these steps:
First, click your “Name” column, and choose Geographic Role. Change this to “State/Province.”
Next, drag and drop your “Name” column in the larger area that reads Drop field here. Tableau will attempt to make a map, but won’t be able to locate the states at first.
Look for the grey box in the lower-right hand corner of the screen that says “32 unknown.” Click, and choose “Edit Locations.”
Change the value in the “Country/Region” drop-down menu to Mexico. The states should now match, so click OK. You should now see a map of Mexico, with dots!
Look for the “Marks” card to the left of the map, and change the drop-down menu to “Map.” You’ll see the states of Mexico appear as polygons!
Use the GIF below as a guide if you are getting stuck.
Now would be a good time to save your work. Click File -> Save to Tableau Public, and sign in with your username and password. Give your workbook a name, and click Save to save your workbook to Tableau’s public cloud. Recall that with the free version of Tableau that we are using, you cannot save your work locally; the paid versions allow you to do this, however.
Now, it is time to style your map. We’ll be mapping primary sector employment by state, so locate the “Pri10” column from the Measures section and drag and drop it on the Color icon in the Marks card. Your map’s states should now become colored based on their values for primary sector employment, using a default continuous sequential color ramp. To change the colors of your map, click the Color icon and select Edit Colors; you can then choose a variety of color palettes from the drop down menu provided, and switch to a binned color scheme by checking the “Stepped Color” box, if you prefer. A legend will also appear in a sidebar; you may need to move the “Show Me” options to see it. You can modify the text in the legend by clicking “Edit Title.”
You now have an interactive Tableau map of Mexico! Save your work once more before proceeding to the next section.
Charting primary sector employment in Mexico with a dot plot¶
The other visualization scenario we discussed in class was a dot plot, created in
seaborn with the
stripplot() function. Tableau has built-in support for this and many other chart types as well.
To get started creating your chart, click Worksheet -> New Worksheet from the top drop-down menu. You’ll get a blank Tableau workspace, just like you had before making your map. You’ll be using same data, but visualizing it in a different way. Follow these steps to create the dot plot.
Drag and drop your “Name” column on the Rows shelf.
Drag and drop your primary sector employment column on the Columns shelf. You should now see a bar chart appear by default.
Sort your bars in descending order by clicking the icon from the top menu that looks like descending bars.
On the Marks card, change the drop-down menu value to Circle. This will create a dot plot.
Drag and drop your primary sector employment column on the Color icon, and style your dots with the same color palette you used for your map.
Add horizontal grid lines to your chart. To do this, click Format -> Lines. Then, click the Rows tab, and add Grid Lines. Next, click the Columns tab, and remove the Grid Lines.
Use the GIF below as a guide if you get stuck.
Save your work. You now have both an interactive map and an interactive dot plot! The next step is to get the two visualizations to interact with one another in a Tableau dashboard.