When referring to a two and three-dimensional plane, a y-axis or vertical axis refers to the vertical height of a two or three-dimensional object. In the illustration, the y-axis plane moves up and down and intersects with the x-axis and z-axis.
An example of what uses the y-axis is a computer mouse. Moving the mouse up or down increases and decreases the y-axis value, allowing the computer to know where the mouse cursor is on the screen.
JavaScript y-axis mouse position
Below is a JavaScript that shows you the mouse’s x-axis and y-axis position as you move your mouse pointer in the screen area.
Other examples of a y-axis
Below are a few other examples of how the y-axis is used on a computer.
If you’re on a smartphone or tablet, tap your finger to get position of the tap.
Mouse x-axis position. Mouse y-axis position.
- Help position and keep track of the mouse cursor on the screen.
- A character or another object in a computer game that moves up and down on the screen has a y-axis value that determines its location.
- With a chart, the y-axis is the data expressed vertically. The higher a data point is represented vertically, generally, the greater the value of the data which corresponds with that point on the x-axis.
- In computer graphics, if you want to draw a vertical line, use the y-axis to determine the start and end point of the line. Drawing a two-dimensional object requires only the x-axis and y-axis. However, a 3D object requires a z-axis.
- Other input devices like a joystick also use a y-axis to control objects such as a tank or airplane.
Absolute coordinates, Axis, x-axis, z-axis