Continuous vs. Discrete

Understanding the differences between continuous and discrete datasets will make choosing scales easier.

It is time to dive into other scales. D3 offers a variety of scales out of the box. We can find a full list of scales provided by D3 here.

This repository will document the various scales available. Let’s take the time to explore the other scales available from D3. It may seem like the scaleLinear() function can cover all our needs. The truth is, there are other scales available that can do a better job, depending on what we’re trying to draw.

This section will be dedicated to exploring the other scales. By the end of it, you will be comfortable navigating around the documentation. Before we dive into scales, there is one important concept we need to understand.

Let’s talk math

Let’s step aside from D3 for a moment and talk about mathematics. Math is not the most exciting topic, but D3 borrows a lot of its concepts from mathematics. There is a specific topic that D3 revolves around, which is continuous and discrete datasets. Generally speaking, data can be put into two categories. Data can be continuous, or it can be discrete. What do these two words mean?

Data is considered continuous if it can be measured. If data can be counted, then it is discrete.
Let’s dive into each one.

Continuous

We will start with continuous data. Continuous data can be measured, and it can take any numerical value, including fractions and decimals. For example, our weather data was continuous. Temperature and humidity can be measured. It is even possible for temperature to be measured to the nearest decimal value. If the possible values are infinite or almost infinite, there is a good chance the data is continuous.

Discrete

Next, let’s talk about discrete data. Discrete data can be counted. Unlike continuous data, discrete data can not be broken down into fractions or decimals. For example, let’s say we had a dataset of the number of tickets purchased for a concert. People can not purchase half a ticket. You either have one, or you do not. Tickets are counted, not measured. Discrete data has a finite number of possible values.

Differences

Let’s compare examples side-by-side. Examples of datasets that are continuous are the following: temperature, height, distance, and time. All these examples are things we can measure.

Examples of discrete datasets are the following: the number of tickets purchased at a concert, the number of books in a library, the number of employees at a company, and the number of text messages sent in a day. These are examples of things we can count.

Simple, right? It is important to understand this concept. There are dozens of scales available in D3. It can be tough to decide which one to use. Before choosing a scale, you need to ask yourself one crucial question. Is your data continuous or discrete? Based on your answer, you will be able to narrow down your choices.

In the next few lessons, we will begin exploring some scales. We would not be able to explore every scale, but we will explore the most important ones. By the end, you will be able to pick up other scales. We will even use some of these scales in the later sections of this course.

Get hands-on with 1200+ tech skills courses.