Clamp Function

Get introduced to the clamp scale and look at some examples.

We'll cover the following

Introduction

Let’s look at an important function, the clamp function. It is very useful when dealing with scales because it helps us to clamp/attach our domain to a given range. In a linear and logarithmic scale, if we give a value outside the domain, it will interpolate the range value outside our specified range, which is not desirable.

Example

To see how a scale can give a value outside the specified range, let’s look at an example of a linear scale.

Get hands-on with 1200+ tech skills courses.