Use Axes.tick_params() to control which sides display tick marks in Matplotlib. For y-axis ticks, set left and right; for x-axis ticks, set bottom and top. Tick labels have separate controls, so you can show marks on both sides while keeping labels on just one.
Show y-axis ticks on the left, right, or both
Call tick_params on the Axes you want to change. This example shows y-axis tick marks on both sides while leaving the labels on the left, then enables x-axis tick marks at the top and bottom while keeping labels at the bottom.
As an Amazon Associate I earn from qualifying purchases.
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2, 3], [2, 1, 4])
ax.tick_params(axis="y", left=True, right=True,
labelleft=True, labelright=False)
ax.tick_params(axis="x", bottom=True, top=True,
labelbottom=True, labeltop=False)
plt.show()
To hide a side, set its side flag to False. For example, ax.tick_params(axis="y", right=False) disables right-side y tick marks. The equivalent x-axis flags are bottom and top. Matplotlib’s axis-ticks guide uses the same approach to place y ticks on the right instead of the left.
Control tick marks and tick labels independently
A tick mark is the short line at a tick location; its label is the number or text beside it. They are configured separately. Use left, right, bottom, or top for the marks, and the corresponding labelleft, labelright, labelbottom, or labeltop flag for labels.
#1 Best Overall
- Show right-side y marks but hide their labels:
ax.tick_params(axis="y", right=True, labelright=False). - Hide right-side y labels without changing the tick marks:
ax.tick_params(axis="y", labelright=False). - Show top x labels while retaining bottom marks: set
labeltop=Trueand configuretopindependently.
This distinction is useful when a plot needs tick references on both edges but duplicate numbers would add clutter.
Choose an axis and tick class
The axis argument scopes a call to "x", "y", or "both". The which argument scopes it to "major", "minor", or "both" tick classes. For example, ax.tick_params(axis="y", which="minor", right=True) targets minor y ticks on the right.
The same method also sets appearance. Common options include length, width, direction, color, label size and color, label rotation, and label padding. Grid styling options are available through tick_params as well. See the official guide for examples and the full set of options.
Recommended Free Tools
Set defaults for multiple figures
For a project-wide default rather than a one-Axes adjustment, use Matplotlib rcParams or a style sheet. The configuration reference lists side visibility, label visibility, major and minor tick sizes and widths, tick direction, and minor-tick visibility. For example, ytick.right controls right-side y tick marks, while ytick.labelright controls right-side y tick labels. Consult the configuration reference for the available settings and how to apply them.
Rank #3
When to move the axis presentation
Enabling ticks on the top or right is not necessarily the same as relocating the axis presentation. If the goal is to move ticks and labels to the top or right, rather than simply show marks on another side, use Matplotlib’s dedicated “Move x/y-axis ticks and labels on top and right” gallery example.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Why per-tick edits are usually less reliable
Individual Tick objects expose their two tick lines as tick1line and tick2line, and their labels as label1 and label2. But Matplotlib can create, move, or delete ticks as view limits change, so edits to a particular tick object may not persist. The axis-ticks guide notes that it is usually simplest to use tick_params to change all the objects at once.
The examples here follow the stable Matplotlib documentation labeled 3.11.2, accessed October 7, 2026. If you use a different installed version, check its documentation for version-specific behavior.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




