DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk3 min

Show or Hide Left and Right Tick Marks in Matplotlib

Control Matplotlib tick marks on opposite sides of an Axes with tick_params, and manage tick labels independently.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

  • 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=True and configure top independently.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

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.Support on Ko-Fi

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.