X-axis

Updated: 10/07/2019 by Computer Hope
Diagram of X-axis, Y-axis, and Z-axis.

With 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 the y-axis and z-axis.

An 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, allowing the computer to know where the mouse cursor is on the screen.

JavaScript x-axis mouse position

Below is a JavaScript that shows the mouse's x-axis and y-axis positions as you move your mouse pointer in the screen area.

Note

If you're on a smartphone or tablet, tap your finger to get the position of the tap.

Mouse x-axis position.
Mouse y-axis position.

Other examples of an x-axis

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

  • Help position and keep track of the mouse cursor on the screen.
  • A character or object in a computer game that moves left and right has an x-axis value determining its location on the screen.
  • With a chart, the x-axis is the horizontal data that is often along the bottom of the chart.
  • In computer graphics, to draw a horizontal line, the x-axis can 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.
  • Other input devices, like a joystick, also use an x-axis to control objects, like a tank or airplane.

Absolute coordinates, Axis, y-axis, z-axis