Setting the Tick for a Plot

In this lesson, we will learn how to set the tick for a plot

What is the tick?

The tick is a mark on the coordinate axis that shows specific points. The tick can be a number, a string, or any other notation. When plotting a graph, the axes will set a default tick based on the number ranges of the different axes. In most cases, this default setting is enough. In some cases, however, we may want to set some more customized ticks.

Matplotlib provides many useful functions for manipulating the tick. We can set the x/y axis independently, or we can set them both with the same property.

The following are some properties that we can manipulate by setting parameters:

  • which: Sets the x/y major/minor ticks. The default value is major.
  • color: Sets the tick color.
  • labelrotation: Rotates the tick label.
  • width: Sets the tick width in points.
  • length: Sets the tick length in points.
  • direction: Sets the direction of the ticks, either towards the axis or away from it. The default value is out.

We won’t talk about all of these properties. Instead, we will focus on the most widely used ones.

Notice: So far, we have learned three methods for creating a graph. In this course, we are always operating from an axes object. If you’ve seen some functions/methods that are different from the ones in this course, they may have been operating from plot.