examples of histograms - tom kleentomkleen.com/ir/2019-fall-dataviz/notes/006-tableau... · web...

12
Tableau Histograms What is a histogram? From Wikipedia: A histogram is an accurate representation of the distribution of numerical data. It is an estimate of the probability distribution of a continuous variable and was first introduced by Karl Pearson. [1] It differs from a bar graph , in the sense that a bar graph relates two variables, but a histogram relates only one . To construct a histogram, the first step is to "bin " (or "bucket ") the range of values—that is, divide the entire range of values into a series of intervals—and then count how many values fall into each interval. The bins are usually specified as consecutive, non-overlapping intervals of a variable. The bins (intervals) must be adjacent, and are often (but not required to be) of equal size. Examples of histograms

Upload: others

Post on 23-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Examples of histograms - Tom Kleentomkleen.com/IR/2019-Fall-DataViz/Notes/006-Tableau... · Web viewA histogram is an accurate representation of the distribution of numerical data

Tableau HistogramsWhat is a histogram? From Wikipedia:

A histogram is an accurate representation of the distribution of numerical data. It is an estimate of the probability distribution of a continuous variable and was first introduced by Karl Pearson.[1] It differs from a bar graph, in the sense that a bar graph relates two variables, but a histogram relates only one. To construct a histogram, the first step is to "bin" (or "bucket") the range of values—that is, divide the entire range of values into a series of intervals—and then count how many values fall into each interval. The bins are usually specified as consecutive, non-overlapping intervals of a variable. The bins (intervals) must be adjacent, and are often (but not required to be) of equal size.

Examples of histograms

Page 2: Examples of histograms - Tom Kleentomkleen.com/IR/2019-Fall-DataViz/Notes/006-Tableau... · Web viewA histogram is an accurate representation of the distribution of numerical data

Open Tableau and connect to UK-Bank-Customers.xlsx.

Go to Sheet 1 and click on Show Me. All choices are grayed out because we haven't selected any data. But we can still get tips from Tableau. Pause the mouse over the Histogram button. Tableau tells us that a histogram is for one measure and that it creates bins.

Click on the Age measure. Histogram should become enabled in the Show Me area. Click on it.

Tableau will automatically create the following on the Rows and Columns shelves:

And it will draw the following histogram for us:

Page 3: Examples of histograms - Tom Kleentomkleen.com/IR/2019-Fall-DataViz/Notes/006-Tableau... · Web viewA histogram is an accurate representation of the distribution of numerical data

Tableau creates bins for age groups. We can change the size of the bin. Right-click on Age(bin) but it has to be in the Dimensions group, not on the Columns shelf.

In the Dimensions group (not in the Columns shelf), click on the down-arrow of the Age(bin) item. Then click on Edit…:

In the Edit Bins [Age] dialog box, change the Size of bins from 3.92 to 5. Click on OK.

Page 4: Examples of histograms - Tom Kleentomkleen.com/IR/2019-Fall-DataViz/Notes/006-Tableau... · Web viewA histogram is an accurate representation of the distribution of numerical data

Your histogram will change to look like this:

Let's change the axis so that the numbers only appear on the borders between the bins. Right-click on one of the numbers on the axis and click on Edit Axis…

The Edit Axis [Age(bin)] dialog box will appear. Click on Tick Marks. Under Major Tick Marks, click on the Fixed radio button. Enter 5 for the Tick Interval.

Page 5: Examples of histograms - Tom Kleentomkleen.com/IR/2019-Fall-DataViz/Notes/006-Tableau... · Web viewA histogram is an accurate representation of the distribution of numerical data

Adding number labels to the tops of the barsLet's add numbers to the top of each bar representing the count of the number of customers in each category.

If we just try to drag CNT(Age) to the label card in the Marks box, Tableau removes it from the Rows shelf, which we do not want. But if we hold the control key down while dragging, Tableau will keep CNT(Age) in the Rows shelf, and our histogram will now look like this:

If we want to see percent values instead of totals, we need to change two things: (1) the numbers on the y-axis to percentages, and (2) the numbers on the top of each bin to percentages. To change the numbers on the axis, we need to change the CNT(Age) pill in the Rows shelf. Click on its down-arrow, then click on Quick Table Calculations, then click on Percent of Total. The numbers on the y-axis will change to percentages.

Page 6: Examples of histograms - Tom Kleentomkleen.com/IR/2019-Fall-DataViz/Notes/006-Tableau... · Web viewA histogram is an accurate representation of the distribution of numerical data

To change the numbers at the top of each bin, we need to change the CNT(Age) pill in the Marks group. Click on its down-arrow, then click on Quick Table Calculation, then click on Percent of Total.

Your histogram should now look like this:

Page 7: Examples of histograms - Tom Kleentomkleen.com/IR/2019-Fall-DataViz/Notes/006-Tableau... · Web viewA histogram is an accurate representation of the distribution of numerical data

Change the format of the numbers on top of the bins to percent with 0 decimal places. On the Rows shelf, click on the down-arrow for CNT(Age). Click on Format….

The data fields at the left get covered by the Format % of Total CNT(Age) pane:

Click on the Default, Numbers down-arrow. The following dialog box will appear. Click on Percentage then reduce the number of decimal places to 0. Then close the Format % of Total CNT(Age) pane.

Page 8: Examples of histograms - Tom Kleentomkleen.com/IR/2019-Fall-DataViz/Notes/006-Tableau... · Web viewA histogram is an accurate representation of the distribution of numerical data

Change the titles1. Change the title to Customer Distribution by Age. The easy way to do this is to

change the title of the worksheet tab at the bottom.2. Change the y-axis title to Percentage of Customers.3. Change the x-axis title to Age.

Add colorMake it pretty by dragging the CNT(Age) pill on the Marks card to the Color button. The bars will change to shades of blue that vary according to size.

Page 9: Examples of histograms - Tom Kleentomkleen.com/IR/2019-Fall-DataViz/Notes/006-Tableau... · Web viewA histogram is an accurate representation of the distribution of numerical data

Adding a cumulative percentage lineDrag the Age measure to the right end of the Rows shelf. This gives us two histograms: our original histogram at the top and a new one at the bottom.

Page 10: Examples of histograms - Tom Kleentomkleen.com/IR/2019-Fall-DataViz/Notes/006-Tableau... · Web viewA histogram is an accurate representation of the distribution of numerical data

Click on the down-arrow at the right edge of the SUM(Age) pill and click on Measure (Sum), then click on Count.

Histogram #2Connect to Math Scores.xlsx.

Click on the College Math Scores field.

Click on Show Me and select histogram.

Click on the down-arrow next to College Math Scores (Bin)

Click on Edit.

Set the Size of Bins to 50 and click on OK.

Turn on labels (click on the "T" icon—Show Mark Labels—on the toolbar).

Page 11: Examples of histograms - Tom Kleentomkleen.com/IR/2019-Fall-DataViz/Notes/006-Tableau... · Web viewA histogram is an accurate representation of the distribution of numerical data

Change the labels to percentages.Click on the down-arrow on the CNT(College Math Scores) pill on the Rows shelf.

Click on Quick Table Calculations.

Click on Percent of Total. The labels will change to percentages.

Add a running sumDrag College Math Scores to the Rows shelf.

Click on its down-arrow.

Click on Measure.

Click on Count. A second histogram will appear at the bottom.

Click on the down-arrow of the second CNT(College Math Scores) pill on the Rows shelf.

Click on Quick Table Calculation.

Click on Running Total. Running totals will now appear.

Click on the down-arrow of the second CNT(College Math Scores) pill on the Rows shelf.

Click on Edit Table Calculation.

Click on the Add Secondary Calculation check box.

Click on the down-arrow under Secondary Calculation Type.

Click on Percent of Total.

Page 12: Examples of histograms - Tom Kleentomkleen.com/IR/2019-Fall-DataViz/Notes/006-Tableau... · Web viewA histogram is an accurate representation of the distribution of numerical data

Click on the "X" to close the dialog box.

Change to a lineRight-click to the left of the y-axis of the bottom chart.

Click on Mark Type.

Click on Line. It will change to a line.

Combine the chartsAgain, right-click to the left of the y-axis of the bottom chart.

Click on Dual Axis. The charts will be combined.

Now you can make some changes in the histogram by right-clicking on the left y-axis and on the line chart by right-clicking on the right y-axis.

Allow an end user to change bin sizeUnder Dimensions, click on the down-arrow of College Math Scores (bin).

Click on Edit Bins…

Under Size of Bins, you can change the size of the bins.

Click on the down-arrow in the Size of Bins check box.

Click on Create a new parameter…

For the parameter Name, enter Bin Size.

At the bottom left of the dialog box, set the Minimum to 10, Maximum to 200, and Step Size to 10.

Click on OK.

Click on OK.

The parameter will appear on the right side of the chart.

Click on the down-arrow next to the parameter.

Click on Slider.