VizWiz

Launch, grow, and unlock your career in data
Showing posts with label density. Show all posts

March 16, 2023

How to Dynamically Resize Marks in Tableau

No comments

In this video, I show you how to resize marks (in this case circles) dependent on how many marks are in the view. For example, if all possible marks are in the view (100%), the circles should be small. If only 10% of possible marks are in the view, the circles should be large.

I show how to do this on a map, but it can be extended to scatter plots, box plots, dot plots, jittered bar chart, and more.

July 5, 2022

How to Create a Hexbin Map in Tableau

No comments

In this tip, I show you how to create a hexbin map in Tableau. But first, let me explain the purpose, benefits and drawback of a hexbin map.

There are countless times when I have been asked to display way too much data on a map. Sometimes I’ve been asked to display thousands of points on a map..but why? I know no one will understand it. 

A hexbin map uses hexagons to divide an area into multiple parts and assign a color gradient to each hexagon. This chart type is used to visualize density, where the hexagons dividing the whole space into discrete units of equal size. 

This video is going to help you communicate the concentration of data on maps more effectively and give you another option for visualizing geospatial data. I’ll show you how to create a hexbin map based on both the value and the rank, giving you two options depending on your use case.

If you want to follow along, these are the data sources I used:

1. Austin Bike Accidents - https://bit.ly/AustinBikeAccidents

2. Austin Zip Codes Shapefile - https://bit.ly/AustinZipCodes

3. Price Summary - https://bit.ly/PriceSummary

February 22, 2021

#MakeoverMonday Week 8 - Protests Against Limiting Abortion Rights in Poland

No comments
On 22nd of October 2020, in the middle of a pandemic, the Constitutional Tribunal of Poland ruled abortion in case of fetal malformations unconstitutional. In this week's Makeover Monday, I ask where and when were the protests that followed?

Watch Me Viz



October 20, 2020

#TableauTipTuesday: Four Methods for Creating Dots on a Map

No comments

People love maps. Putting dots on a map gives a sense of precision. There are lots of methods for displaying maps. In this video, I show you four:

  1. The exact locations
  2. Density map
  3. Using the ROUND function to generalize the points
  4. Using the HEXBIN functions to generalize the points, but at a level controllable by the user

June 19, 2020

How to Get Your Data from Strava to Tableau

No comments
UPDATE: If you prefer video tutorials, there is now one on my YouTube channel here. The steps to get the links into the Simple Mass Downloader are done more efficiently in the video. There are several steps removed from the Excel and link uploads that are listed in the blog.




For a while now, I've been using this process for getting my data from Strava into Tableau like this:
  1. Download the data from Strava
  2. Prep it with Alteryx
  3. Visualize it in Tableau

In this post, I will outline the steps for getting your data from Strava into Tableau. I have also created a template with some sample vizzes for you to use. Download it from Tableau Public here.

I started revamping the process after wanting to create a small multiple view of all of my activities like this:


When I first started creating these, I took a process based on R and converted it into a workflow in Alteryx. This worked great, but there were two main drawbacks:

  1. My Alteryx workflow was a mess (I tinkered with it every month).
  2. Each of the routes would be adjusted to fit perfectly in a square.

This second problem meant that the routes were not scaled correct according to the curvature of the Earth. I then saw that Andy Cotgreave reached out to Ken Flerlage for help. They've written about their process here. Great! However, the calculations on this process make rendering the maps in Tableau very, very slow. Like REALLY slow.

That's where Alteryx comes in. I pushed all of the data processing into Alteryx, export each route as a single spatial object and every renders super fast. So if you're interested in getting all of your data out of Strava and visualizing it in Tableau, this process is for you. It does require Alteryx, but you could replicate the process in R.


TOOLS REQUIRED

  • A Strava account - NOTE: Make sure you are logged in to Strava throughout these steps.
  • Alteryx Designer
  • Tableau Desktop
  • Simple Mass Downloader Chrome extension

GET THE DATA FROM STRAVA

Step 1 - Login to Strava, click on your profile icon on the upper right, choose Settings.


Step 2 - On the My Profile page, click on My Account.


Step 3 - Scroll to the bottom and click on the Get Started button in the Download or Delete Your Account section.


Step 4 - In step 2, choose Request Your Archive. Don't do anything else on this page.




Step 5 - Check your email in a few minutes. When it arrives, click on the Download Archive button in the email.



Step 6 - Unzip the file that downloads. Open the folder that's created and you should see something like this.

The activities folder contains all of the raw files, but these won't all be in the same format, which means they're useless. The ONLY file we need is activities.csv. Open the CSV in Excel.

Step 7 - The only column we need in the file is the Activity ID column.


Delete all columns except Activity ID.


Step 8 - Insert a column to the left of Activity ID. I name it URL, but call it whatever you prefer. Then in cell A2 enter this formula: 

=CONCAT("https://www.strava.com/activities/",B2,"/export_gpx")

Then copy it down for all rows. This create a link to each activity in GPX format. If some of the activities don't have location data, don't worry about it. Those will simply not download in the process.

Choose the URL column header (the "A" above URL), choose Copy, then Paste Special => Values. Then delete column B (the column with the activity ids).



DOWNLOAD EACH ACTIVITY

Step 1 - Add the Simple Mass Downloader Chrome extension.


A new tab will open with a tutorial if you're interested to learn how it works.

Step 2 - Click on the extension button and you should see this screen.



Step 3 - Click on the hamburger on the right and choose Import URLs from local file.



Step 4 - Import the activities.csv file and the URLs will upload. This loads all of the files into the queue on the Download List tab. Choose the Select All box and they should all be highlighted.



Step 5 - Click on Start Selected and you'll see a bunch of files start downloading very quickly. Again, some of them will error out if the activity doesn't have location data. The files that download will have a green check next to them.



Phew! That might seem like a lot, but once you do it a couple times, the process is really quick.

Fantastic...all of the files are now downloaded. Onto Alteryx we go. 

ALTERYX PROCESS

Step 1 - Download the Strava Route Maps workflow from the Alteryx Gallery and open it in Alteryx Designer. If you can't download it from the Gallery, I have it on Google Drive here.


The Strava icon is a simple macro that will import all of the GPX files in the Directory you specify when you run the app. 

The workflow is split into four parts:

  1. Import the data, strip out the parts we need, then create points and lines.
  2. Normalize the data based on the calcs from Ken Flerlage, turn them into lines (one mark for each route rather than hundreds of point for each route) and export as a Tableau extract.
  3. For each point, calculate the distance, climb, etc. and extract all of the points.
  4. Take each of the points and turn them into lines.

Neither part 3 nor part 4 above normalize the data into squares. These are simply all of the data for each route.

Step 2 - Run the workflow as an App by clicking on the magic wand next to the Run button.


Step 3 - Choose the folder that contains all of the GPX files from the Simple Mass Downloader output. And click Finish.


This will generate three Tableau extracts that will load into the same directory as the GPX files. The workflow extracts them as TDE because Hyper files don't support polygons. Even though these aren't polygons, it makes me more comfortable that Tableau will read the files correctly.

Success!


Click the Clear button and then the OK button. Otherwise all three files will open in Tableau, which we don't want.

We're all done with Alteryx. Onto Tableau.


TABLEAU PROCESS

I've created a template for you to get started with. Download it from my Tableau Public profile here. Once you have done that, follow these steps.

Step 1- Open Tableau and right-click on each data source and pick Edit Data Source.


Step 2 - Click on the carrot next to the data source name and choose Edit Connection.


Step 3 - Navigate to the data source that downloaded from the Alteryx workflow. It will have the same name.



Step 4 - Go back to your worksheets and everything should update automatically. If not, right-click on the data source name and choose Refresh.

Step 5 - Customize the views as you see fit. That's it!

Here are the vizzes that I have included in the template.










July 2, 2019

#TableauTipTuesday: Fun with Maps

No comments
Dot maps, density maps, round maps, square maps, hexbin maps, emoji maps...this video shows you how to build all of them.

February 22, 2019

Where are New York's Parking Meters?

No comments
There are times when you come across a data set that you immediate know will look cool as a visualization. New York City open data had, what I thought, was a pretty obscure dataset: Parking Meters GPS Coordinates and Status.

Their map is impossible to read with some many big dots overlapping each other. This also makes it hard to see the concentration of parking meters. My assumption going in was that you'd see way more in Manhattan.

All I really did was create a map, plot each point, and change the mark type to Density. From there it was formatting:

  1. Using a custom mapbox map, which I customized based on the mapbox template Metropolis.
  2. Play around with lots of colors, then intensity and opacity of each of those colors, before settling on a choice. 

I probably could have done this process for days and days without ever finding a "perfect" solution for the formatting, so I decided it's good enough and wanted to get it published. Enjoy!

October 31, 2018

Analyzing Pitcher Performance With Density Heatmaps

No comments
With Tableau 2018.3 comes density heatmaps, a feature I've been playing with quite a bit and love it for when I have a dense concentration of points and a regular scatterplot doesn't work well. Transparency can help with dense dots, but I think the heatmaps work much better.

To give it a test, I downloaded every pitch for Clayton Kershaw and Justin Verlander (two of the best pitchers in Major League Baseball) from 2008-2018 from the great stats website Baseball Savant. Every time I look at baseball data, I'm amazed at the detail of the stats covered; the data far exceeds anything that is covered in other sports.

After downloading the data, I built the small multiples view below for each pitcher so that I could see their progression through the years. Click on the images for the interactive versions. I love how the data shows me how each pitcher has gotten better with their "misses" through their careers. For example, when they throw sliders for balls, they now tend to miss below the strike zone. This is a great sign that they have command of their pitches and are less likely to miss in an area where the batter can take advantage.

The density heatmap feature will most likely be used by most people on maps, which makes sense, but consider looking at it as an alternative whenever you need to plot x/y coordinates and have lots of points to display.



September 13, 2018

Clayton Kershaw & My Learning Process

No comments

What is Learning?

According to UC Berkley, learning is a process that:

  1. is active - process of engaging and manipulating objects, experiences, and conversations in order to build mental models of the world (Dewey, 1938; Piaget, 1964; Vygotsky, 1986). Learners build knowledge as they explore the world around them, observe and interact with phenomena, converse and engage with others, and make connections between new ideas and prior understandings.
  2. builds on prior knowledge - and involves enriching, building on, and changing existing understanding, where “one’s knowledge base is a scaffold that supports the construction of all future learning” (Alexander, 1996, p. 89).  
  3. is situated in an authentic context - provides learners with the opportunity to engage with specific ideas and concepts on a need-to-know or want-to-know basis (Greeno, 2006; Kolodner, 2006).
  4. requires learners’ motivation and cognitive engagement to be sustained when learning complex ideas, because considerable mental effort and persistence are necessary.

I've left a couple bits out that aren't relevant to learning in the context of data visualization, but all of the others should resonate with you if you approach learning with the correct mindset.

As an example, I am actively look for reasons to practice features in the Tableau 2018.3 beta, especially around density mapping. I was reading an article this morning about Clayton Kershaw, whom many consider the best pitcher in Major League Baseball. He also has highest base salary at $33M for 2018.

Most of the density maps I've seen have had a mapping component. In the case of baseball, and pitching in particular, the spatial zone is the strike zone. Data is easily accessible to get the coordinates of every pitch as it crosses home plate.

For this project, the learning process:

  1. is active in that I am building my knowledge as I explore the data set and learn the new features.
  2. builds on my prior knowledge of how the feature works and my knowledge of the game of baseball. However, I had never done a scatterplot of pitching before, so I had to learn new terminology in the data. This knowledge will help me be more productive and learn faster in the future.
  3. is situated in the authentic context of engaging with the ideas and visual concepts that I saw online and drew on paper.
  4. required my motivation and engagement to see the project through to fruition and the persistent to make the display visually accurate.

I hope my thought process helps you focus your learning. I love helping people get better at what they do and if I can help you speed up your learning, then we'll all be better for it.

With that in mind, here are two images I created for this project. The first is all pitches by Kershaw and the second is of his curveballs, which is known to be his most potent pitch. Once Tableau Public supports Tableau 2018.3, I'll publish them and include links on the images.