X-axisWhen referring to the cartesian plane, the x-axis or horizontal axis refers to the horizontal width of a two or three-dimensional object. The illustration shows the x-axis as going left-to-right and intersecting both the y-axis and z-axis.

A good example of what uses the x-axis is a computer mouse. As the mouse moves left or right the x-axis value increases and decreases, which allows the computer to know where the mouse cursor is on the screen. Below is a JavaScript script, which if enabled shows you the mouses x-axis and y-axis position as you move your mouse on your screen.

JavaScript X-axis mouse position example

Mouse X-axis position
Mouse Y-axis position

Other examples

Below are a few other examples of how the x-axis is used on a computer.

  • A character or another object in a computer game, which moves left and right on the screen has an x-axis value that determines its location on the screen.
  • In computer graphics, if you wanted to draw a horizontal line the x-axis can be used to determine the start and end point of the line. Drawing a two-dimensional object would require only the x-axis and y-axis. However, a 3D object would require a z-axis.
  • In addition to the mouse, other input devices like a Joystick also use an x-axis to control objects such as a tank or airplane.

Also see: Axis, Y-axis, Z-axis