Metabase offers a large number of visualization options. For this article, we’ll use the bar chart option to create a histogram, a type of bar chart that displays groups of data across a continuous range.
Histograms are helpful for gaining insights into how much of an item people are likely to buy, the price range they are likely to purchase within, or even the time of year that most people make purchases.
We’ll specifically cover:
Histograms versus bar charts
Histograms are a type of bar chart. While the bars on a typical bar chart represent categorical groups, the bars on a histogram represent ranges along a continuous, quantifiable spectrum.
In other words, you split the data into bins in order to view the distribution of values within a range. The bins are of equal length (and can be empty), and the bins are contiguous. The height of each bar represents the count (or proportion) of the items in the bin. The number of bins is up to the user, though Metabase will automatically select the number of bins for you.
Let’s see the difference between a bar chart and a histogram using the Sample Dataset included with Metabase. Figure 1 shows a bar chart that displays the count of people from the People table grouped by referral source. Figure 2 shows the histogram we’ll create in the walkthrough below.
Metabase makes it easy to create a histogram. In fact, if the data is suitable for a histogram, Metabase will automatically create a histogram for you.
Create a histogram
Follow along with Metabase’s Sample Dataset to create the histogram detailed below.
From the main navigation bar, select Ask a question and create a simple question using the Sample Dataset and its Orders table.
From the Orders table, click on the green Summarize button. Scroll down and select ‘Total’ (figure 3), and click the + button to add the grouping. Metabase will automatically create a histogram for you!
The histogram shows that customers are most likely to make purchases totaling in the $30-60 range. If you hover over one of the bars, Metabase will display the count of orders in that range. You can also click on a bar to drill-through the data and see the orders that compose the bar.
Edit a histogram
Metabase gives you many different options to customize a bar chart. For now, we’ll hone in on the settings that make histograms shine.
Metabase will automatically set the number of bins, but you can change how Metabase bins the data. Click on the green Summarize button, scroll down to # Total, and click on Auto binned. A dropdown menu will present the options: Auto bin, 10, 50, or 100 bins, or Don’t bin. See figure 5.
Click the Settings button in the bottom left corner. In the Settings sidebar, select the Axes tab. The x-axis scale currently says “Histogram.” Metabase detects when your bar chart should present as a histogram, and selects the best x-axis scale for your visualization.
If you toggle between the three options (Figure 5), you’ll see that “Histogram” is the only Axes option in which the bars are flush with each other.
The flush bars communicate that the x-axis represents a continuous range of data. Linear axes are good for displaying data in categories (figure 1). Ordinal axes are good for displaying data that’s grouped in distinct number categories. For example, displaying how many ratings you receive that are either 1, 2, 3, 4, or 5.
Ordinals differ from histograms because Ordinals group by distinct number values, rather than a continuous range of values.
You can also change the scale of the y-axis to make your chart easier to interpret. If the range of your data along the y-axis is tall, consider using a logarithmic scale. If your range is compact, you can display counts using a power scale.
Since Metabase has already done a good job visualizing our data, the only change we’ll make to our histogram will be to add more descriptive labels.
Click “Labels” and scroll down so you can see the text boxes with the current axes labels. Change the y-axis label to “Count of Orders”, and the x-axis to “Order Total”.
The original label was general, but our new label is more specific and easier to understand. You can make other visualization changes, but Metabase has already done a good job displaying your data as a handsome histogram.
We’ll cover more visualizations types in future posts. In the meantime, check out: