Linear Scale

Introduction to the linear scale

We'll cover the following

Scales are functions that map input from a domain to output in a range. They take an input, typically a data point, and convert it into position, length, and color.

We will cover the linear scale, which maps continuous input to continuous output.


Let’s look into the detail of the scales and explore the linear scale, the most common scale and an automatic choice when we want to map continuous input to continuous output. The linear scale maps continuous input to continuous output through a linear function.


Where x is the input, and y represents the output. Input is generally data such as the population of cities, and output is generally a dimension graph, which will be covered in the next chapter.


Now, we are going to look at an example to further understand how the linear scale works. Let’s look at an example where we want to convert the student 10-point CGPA ranging from 0 to 10, to the 4-point CGPA system ranging from 0 to 4 with a linear scale function.

We will use the domain() and the range() functions to define the domain and range for the scale respectively.

Get hands-on with 1200+ tech skills courses.