The Y-axis

Drawing the y-axis for a chart is a similar process to drawing the x-axis with a slightly different function.

We are going to draw the y-axis for our scatterplot. The y-axis will measure the temperature. The process is going to be similar to drawing the x-axis. You have the knowledge to tackle this task, so try to draw a y-axis as an exercise. Scroll down to the bottom to view the final solution and walkthrough. Good luck!

The solution

If you were able to draw a y-axis, congrats! If not, that is fine, too. We will work on the y-axis together.

Creating the axis function

First, we need to create the function that will draw the axis on our behalf. We will be using the axisLeft() function. This function will draw a vertical axis with the ticks and labels placed on the line’s left side. It is normal for these elements to be positioned on the left side for a scatter plot.

const yAxis = d3.axisLeft(yScale)

We are going to create ...

Access this course and 1400+ top-rated courses and projects.