If you have spent any time building data visualizations in Python, you know that the “default” look isn’t always what you want for a high-end report.
One small detail that often catches my eye—and bugs me—is the direction of the axis ticks. By default, Matplotlib usually points them outward, away from the plot area.
In my ten years of working as a Python developer, I have found that “inward” ticks often provide a much cleaner, more professional “scientific journal” look, especially for academic or financial charts.
In this tutorial, I will show you exactly how to control the Matplotlib tick direction using Python. We will move beyond the basic defaults to create polished, US-market-ready visualizations.
Python Matplotlib Tick Direction
When I first started plotting economic data for US-based clients, I realized that small aesthetic choices impact how people perceive your data’s accuracy.
Ticks that point inward (towards the data) can help frame the plot area more tightly. Ticks that point outward are great for readability but can sometimes interfere with axis labels.
Python gives us total control over this through the tick_params method. While you might be looking for a way to use set_xticks, the direction is actually handled by the properties of the ticks themselves.
Method 1: Use the Python Matplotlib tick_params Method
The most common way I change tick direction is by using the tick_params function. It is efficient and lets you target both axes at once.
In this example, we will look at the average home prices in major US cities. We want the ticks to point “in” to give the chart a modern, framed feel.
import matplotlib.pyplot as plt
# Data: Average Home Prices in USD for 2024 (Hypothetical US City Data)
cities = ['New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix']
prices = [850000, 790000, 350000, 320000, 450000]
# Create the Python plot
fig, ax = plt.subplots(figsize=(10, 6))
ax.bar(cities, prices, color='skyblue')
# Setting tick direction to 'in'
# I use 'both' to apply this to both X and Y axes simultaneously
ax.tick_params(axis='both', direction='in', length=6, width=2, colors='black')
# Adding USA-specific context
ax.set_title('Average Home Prices in Major US Cities (2024)', fontsize=14)
ax.set_ylabel('Price in USD ($)')
ax.set_xlabel('City Name')
plt.show()I executed the above example code and added the screenshot below

In the code above, I set direction=’in’. This tells Python to flip the ticks so they sit inside the plot boundary.
I also adjusted the length and width. If you make ticks point inward, I recommend making them slightly thicker so they don’t get lost against the plot border.
Method 2: Change Tick Direction via Python rcParams Globally
Sometimes, I find myself working on a large project with twenty or thirty different Python charts. I don’t want to manually set the tick direction for every single axis.
In these cases, I modify the global Python Matplotlib configuration. This ensures every plot in my script follows the same styling rules.
import matplotlib.pyplot as plt
# Setting global Python Matplotlib parameters
# This ensures all future plots in this session have inward ticks
plt.rcParams['xtick.direction'] = 'in'
plt.rcParams['ytick.direction'] = 'in'
# Data: Monthly Tech Salary in San Francisco vs. Austin (USD)
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May']
sf_salary = [12000, 12200, 12100, 12500, 12800]
austin_salary = [9000, 9200, 9150, 9400, 9600]
plt.figure(figsize=(10, 6))
plt.plot(months, sf_salary, label='San Francisco', marker='o')
plt.plot(months, austin_salary, label='Austin', marker='s')
plt.title('Monthly Tech Salary Trends: SF vs. Austin', fontsize=14)
plt.ylabel('Monthly Salary (USD)')
plt.legend()
plt.show()I executed the above example code and added the screenshot below

By using plt.rcParams, I save a lot of time. In my experience, this is the best way to maintain brand consistency for US corporate presentations where every chart must look identical.
Method 3: Use ‘inout’ for a Centered Tick Look
A less common but visually striking method is the inout direction. This places the tick mark exactly in the middle of the axis line.
I find this useful when creating high-precision engineering charts for US manufacturing data. It provides a “crosshair” feel that makes it easy to align values.
import matplotlib.pyplot as plt
# Data: Battery Efficiency of US Electric Vehicles over Miles
miles = [0, 50, 100, 150, 200, 250]
efficiency = [100, 98, 95, 91, 88, 84]
fig, ax = plt.subplots(figsize=(10, 6))
ax.plot(miles, efficiency, color='green', linewidth=2)
# Applying 'inout' direction
ax.tick_params(axis='x', direction='inout', length=10, width=2)
ax.tick_params(axis='y', direction='inout', length=10, width=2)
ax.set_title('US EV Battery Efficiency Retention', fontsize=14)
ax.set_xlabel('Miles Driven')
ax.set_ylabel('Efficiency Percentage (%)')
plt.grid(True, linestyle='--', alpha=0.6)
plt.show()I executed the above example code and added the screenshot below

When you use inout, you usually need to increase the length parameter. Since half the tick is inside and half is outside, a standard length of 4 or 5 looks too small. I usually go with 10 for a bold look.
Customize Specific Ticks (Major vs. Minor)
In professional Python development, we often distinguish between major and minor ticks. You might want major ticks to point out and minor ticks to point in.
In this example, we will visualize US Crude Oil production. This requires a detailed axis where tick direction helps separate primary data from secondary intervals.
import matplotlib.pyplot as plt
from matplotlib.ticker import AutoMinorLocator
# Data: US Oil Production (Millions of Barrels per Day)
years = [2018, 2019, 2020, 2021, 2022, 2023]
production = [10.9, 12.3, 11.3, 11.2, 11.9, 12.9]
fig, ax = plt.subplots(figsize=(10, 6))
ax.plot(years, production, color='darkred', marker='d')
# Enable minor ticks
ax.xaxis.set_minor_locator(AutoMinorLocator())
# Major ticks point OUT
ax.tick_params(axis='both', which='major', direction='out', length=8, width=2)
# Minor ticks point IN
ax.tick_params(axis='both', which='minor', direction='in', length=4, color='gray')
ax.set_title('US Crude Oil Production Trends', fontsize=14)
ax.set_ylabel('Barrels (Millions per Day)')
plt.show()Using the which parameter is key here. It allows you to specify whether you are modifying 'major', 'minor', or 'both'. This level of detail is what separates a beginner Python plot from a professional one.
Troubleshoot Tick Direction Issues
I have noticed a few common pitfalls when developers try to change tick directions in Python.
First, if you have ax.spines turned off or hidden, the ticks might disappear entirely. Ticks are attached to the spines. If you hide the spine, the tick has nowhere to sit.
Second, if you use a style sheet like plt.style.use(‘ggplot’), it might override your tick settings. I always apply my custom tick_params after setting the style to ensure they take effect.
Finally, remember that direction is a string. You must wrap the words ‘in’, ‘out’, or ‘inout’ in quotes, or Python will throw a NameError.
Changing the tick direction in Matplotlib is a simple tweak that makes a big difference. Whether you want a clean inward look for a financial report or a standard outward look for a web dashboard, the tick_params method is your best friend.
In this guide, we looked at how to change directions for specific axes, how to apply them globally using rcParams, and how to handle major versus minor ticks using real-world USA data examples.
You may also read:
- Control Horizontal and Vertical Alignment of xticklabels in Matplotlib
- Customize xtick Labels Using fontdict and fontsize in Matplotlib
- Set xticks Range and Interval in Matplotlib
- Matplotlib Boxplot: Set X-Axis Tick Labels

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.