#MakeoverMonday Week 2019-22 Diary

The data set for this week’s #MakeoverMonday is CO2 emissions per capita, per country, with the original visualization (below) showing the trends of nine selected countries, from 1960 through 2014. So, what works and what doesn’t work with this chart? I don’t mind a line chart displaying the trends of CO2 emissions by country. However, here are a few things I don’t like about the original. The colors are difficult to deal with and I would prefer a solid line vs. the dashed line in the original viz. The country labels block the last 5-10 years of the viz, depending on what line you’re following, so that’s not ideal either. I see in the original, the user has the option of toggling the labels on or off. But, if you turn the labels on and they end up covering part of the viz, I would have gone for an alternative approach to labeling the lines. Alright, let’s get down to business.

 

Step 1. Understanding the Data

The data set is a nice and easy one to work with, giving us Country Name, Country Code and the CO2 emissions for each year, from 1960 to 2014. However, in looking through the data set, the first thing that caught my attention was there are several additional rows of aggregated data, such as ‘Arab World’ and ‘Caribbean small states’ below. Depending on your analysis, you may want to use these, so just be aware that they are there. If not interested in using them, consider throwing a data source filter on Country Name, before jumping into Tableau, and filtering these out, so you don’t have to deal with them.

data

The only other thing with the data set is when pulling it into Tableau, you’ll likely need to take a few small steps to reshape the data;

  • You’ll notice the field names are in row 1 and the headers read F1, F2, F3, etc. To fix this, from the Data Source pane, click on the drop down of the sheet you pulled onto the canvas and select ‘Field Names are in first row.’
  • Next, the years 1960 to 2018 are in columns and we want those in rows instead, so we’ll pivot our data, giving us a tall data set as opposed to the current wide data set.
    • To do this click on the header of the year 1960, hold shift and scroll to 2014, click on that as well. This will select all years from 1960 to 2014. Next, right-click and select pivot.
    • Since there’s no data in the years 2015 to 2018, feel free to hide them.
    • Now, rename your new columns;
      • Change ‘Pivot Field Names’ to ‘Year’
      • Change ‘Pivot Field Values’ to ‘Value’
  • That should leave us with four columns; Country Name, Country Code, Year and Value. Alright, now we’re ready to jump into Sheet 1.

Step 2. Recreating the Original

After taking some time to explore the data, I decided to try something I’m not sure I’ve ever actually done as part of a #MakeoverMonday and that is to make a recreation of the original visualization with the exact same chart types. So, I’ll make a replica of the line chart and look to incorporate the bar charts into my viz as well. With this approach, I’ve defined three goals;

  • Make the viz cleaner
  • Better solution for the labels
  • Improve the interactivity

Usually my goal for #MakeoverMonday is to come up with a better way to visualize the data through the use of a different chart type. However, with this visualization, I feel the line chart and bar chart are good choices, the line chart just needs to be cleaned up and the bar chart is a little blah. What better time to try out Tableau’s BRAND NEW Parameter Actions, featured in the recent 2019.2 release?!!

 

Step 3. Effective Use of Color

I took to Tableau and built exact replicas of the original line chart and bar chart. While I changed a few things formatting-wise, the only thing different with the charts themselves is the use of color. Instead of several different colors on the line chart, I used parameter actions to highlight, in red, the country being hovered on. Likewise, I followed this coloring through to the bar chart, which will end up in a viz in tooltip. Here they are below, as stand alone charts. Using color to highlight a certain country helps the audience to see how that country differs from the others.

 

Tableau’s parameter actions are so easy to use. If you’ve used Set Actions before, the set up is very similar. Here’s all that is required for the three parameter actions in my viz.

  1. Create a parameter using the Country Name field. I called it Country Parameter. This one parameter will be used in all the parameter actions.

countryparam

 

 

 

 

 

 

 

 

2.  Create a Boolean calculation called Country T/F and drag it to both the size card and the color card. Then simply adjust the size to your liking for both the True and False values and do the same for coloring. I adjusted my sizing and color, so when a Country was selected, the line thickened and turned red in color, while the other countries are thin gray lines, pushing them to the background but keeping them plenty visible for comparisons. Quick note: I also dropped this calculation on the color card of my viz in tooltip bar chart, allowing it to highlight the country being hovered on, just like the line chart.

3. Create a calculation that checks to see if the Country Name = the Country Parameter. If True, then it displays the Country Name, if False then it is blank. I dragged this to the label card to label the country being highlighted via the parameter actions. All other countries will receive no label.

Here are the calculations as well as the sheet. To get the label to fit at the end of the line chart, I both fixed the Year axis to add a few additional years and also added 25 pixels of right outer padding to this sheet, once it was dropped onto the dashboard. I could have just done more padding without fixing the axis and got the same result.

 

linesheet

4. Once the sheet was pulled onto the dashboard it was time to set up the Parameter Actions. This is literally all there is to it; from the Menu go to Dashboard –> Actions –> Add Action –> Change Parameter. An Edit Parameter Action dialogue box will pop up. Simply name your action if you’d like, select your Source Sheets, Target Parameter and Field and then set the action to run on either Hover, Select or Menu. I chose to run the action on Hover, as it made the most sense for the interactivity in this viz.

paramaction

Step 4. Formatting

Alright, with the Parameter Actions set up, it was time to finish this thing off with a little formatting. Here are some formatting steps I took to clean up the viz from its original version.

  • Changed the Y-axis tick marks to an interval of 5 instead of 2
  • Changed the X-axis tick marks to an interval of 10 instead of 5
  • Removed the grid lines
  • Changed the default axis font to Tableau Book 8pt, bold and gave it a darker color to help push it to the background
  • Replaced the default tooltips with the viz in tooltip, featuring the bar chart with selected country highlight
  • Added a small message letting the user know to hover for interactivity
  • Changed the background to a darker color…just personal preference

There we go, that’s it. Nothing crazy, but I feel like we gave the original viz a nice makeover, cleaning it up and making it more user friendly. The final product is below and you can play around with the interactive version right here. Thanks for reading and have a wonderful day!!

co2snip

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s