When I first started using Matplotlib in Python over a decade ago, I often found myself struggling with simple but frustrating formatting issues. One of those was flipping or rotating the Y-axis label.
If you’ve ever plotted data and realized that your Y-axis label is upside down, misaligned, or just not visually appealing, you’re not alone. I’ve been there too, especially when preparing charts for presentations or reports.
In this tutorial, I’ll show you how to flip Y-axis label in Matplotlib using Python. I’ll walk you through multiple methods that I personally use in my data visualization projects. Each method is simple, practical, and works across different chart types.
Flip the Y-Axis Label in Matplotlib
Sometimes, the default orientation of the Y-axis label doesn’t match the design or readability needs of your chart.
For example, when creating a dashboard for a U.S. sales dataset, you might want the Y-axis label to appear horizontally or flipped upside down for better alignment with other elements.
Flipping the Y-axis label can also help when you invert the Y-axis itself (for example, when plotting depth measurements, stock prices, or negative values).
Method 1 – Flip Y-Axis Label using set_ylabel() and rotation Parameter
The simplest way to flip the Y-axis label in Matplotlib is by using the set_ylabel() method. This method allows you to set the label text and adjust its rotation angle.
Here’s how I usually do it in my Python projects.
Step-by-Step Example
Let’s say I have a dataset showing average monthly rainfall in different U.S. cities. I want to plot this data and flip the Y-axis label horizontally.
import matplotlib.pyplot as plt
# Sample data for average monthly rainfall (in inches)
cities = ['New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix']
rainfall = [3.9, 2.0, 3.2, 4.3, 0.7]
# Create a simple bar chart
plt.bar(cities, rainfall, color='skyblue')
# Add title and labels
plt.title('Average Monthly Rainfall in Major U.S. Cities')
plt.xlabel('City')
plt.ylabel('Rainfall (inches)', rotation=0, labelpad=40)
# Flip the Y-axis label horizontally
plt.gca().yaxis.set_label_coords(-0.1, 0.5)
# Display the plot
plt.show()I executed the above example code and added the screenshot below.

In this example, I rotated the Y-axis label to 0 degrees using rotation=0. This makes it appear horizontally.
Then, I adjusted the label’s position using set_label_coords() to ensure it’s properly aligned beside the Y-axis.
Method 2 – Flip Y-Axis Label Vertically using Negative Rotation
Sometimes, you may want to flip the Y-axis label vertically (upside down). This is useful when you invert the Y-axis or want the label to match a mirrored layout.
Here’s how you can do it with Python.
import matplotlib.pyplot as plt
# U.S. unemployment rate data (fictional)
years = [2018, 2019, 2020, 2021, 2022]
unemployment_rate = [3.9, 3.7, 8.1, 5.4, 3.8]
plt.plot(years, unemployment_rate, marker='o', color='darkorange')
# Add title and labels
plt.title('U.S. Unemployment Rate (2018–2022)')
plt.xlabel('Year')
plt.ylabel('Unemployment Rate (%)', rotation=180)
# Adjust Y-axis label position
plt.gca().yaxis.set_label_coords(-0.15, 0.5)
plt.grid(True)
plt.show()I executed the above example code and added the screenshot below.

In this method, setting rotation=180 flips the Y-axis label upside down. I’ve used this approach when creating mirrored charts or when the Y-axis is inverted to represent descending order (for example, depth or negative temperature values).
Method 3 – Flip the Entire Y-Axis (and Label) using invert_yaxis()
If you want to flip the entire Y-axis, including the label and tick marks, you can use the invert_yaxis() function in Matplotlib.
This is especially useful in scientific or geological visualizations, such as plotting depth below sea level or temperature gradients.
Here’s a Python example.
import matplotlib.pyplot as plt
# Depth data (in feet) for a well in Texas
depth = [0, 100, 200, 300, 400, 500]
temperature = [68, 70, 74, 78, 81, 85]
plt.plot(temperature, depth, color='teal', linewidth=2)
# Add title and labels
plt.title('Temperature vs Depth in a Texas Well')
plt.xlabel('Temperature (°F)')
plt.ylabel('Depth (feet)', rotation=0, labelpad=35)
# Flip the Y-axis
plt.gca().invert_yaxis()
# Flip Y-axis label horizontally
plt.gca().yaxis.set_label_coords(-0.1, 0.5)
plt.grid(True)
plt.show()I executed the above example code and added the screenshot below.

By calling invert_yaxis(), the Y-axis values are reversed, and larger values appear at the bottom. This is a common technique in Python data visualization when plotting depth or altitude data.
Method 4 – Use ax.yaxis.label.set_rotation() for Fine Control
Another way to flip or rotate the Y-axis label in Matplotlib is by directly accessing the label object.
This gives you more control over the rotation and alignment of the label, especially when creating complex multi-axis plots.
Here’s how I use it in Python.
import matplotlib.pyplot as plt
# U.S. population growth data
years = [2000, 2005, 2010, 2015, 2020]
population = [282, 295, 309, 321, 331] # in millions
fig, ax = plt.subplots()
ax.plot(years, population, marker='s', color='green', linewidth=2)
ax.set_title('U.S. Population Growth (2000–2020)')
ax.set_xlabel('Year')
ax.set_ylabel('Population (millions)')
# Flip Y-axis label vertically
ax.yaxis.label.set_rotation(180)
ax.yaxis.set_label_coords(-0.15, 0.5)
plt.grid(True)
plt.show()I executed the above example code and added the screenshot below.

Here, I used ax.yaxis.label.set_rotation(180) to flip the label vertically. This method is ideal when you’re dealing with subplots or need precise control over multiple axes in the same figure.
Method 5 – Flip Y-Axis Label and Text Alignment Together
Sometimes, flipping the label alone isn’t enough; you may also need to adjust the alignment of the text.
In such cases, I use the set_ylabel() method with both rotation and ha (horizontal alignment) or va (vertical alignment) parameters.
Here’s an example using Python:
import matplotlib.pyplot as plt
# Average U.S. household income (fictional data)
years = [2016, 2017, 2018, 2019, 2020]
income = [57000, 59000, 61000, 63000, 65000]
plt.plot(years, income, color='purple', linewidth=2, marker='o')
plt.title('Average U.S. Household Income (2016–2020)')
plt.xlabel('Year')
plt.ylabel('Income (USD)', rotation=0, ha='right', va='center', labelpad=50)
# Adjust Y-axis label position
plt.gca().yaxis.set_label_coords(-0.1, 0.5)
plt.grid(True)
plt.show()By combining rotation and alignment, you can make your Y-axis label look exactly how you want it.
This approach is especially useful when preparing charts for reports or dashboards where layout precision matters.
Tips for Flipping Y-Axis Labels in Python Matplotlib
Here are some quick tips I’ve learned from experience:
- Use rotation=0 for horizontal labels and rotation=180 for flipped vertical labels.
- Adjust the label position using set_label_coords(x, y) to fine-tune placement.
- If the Y-axis is inverted, flip the label to match the visual flow of the chart.
- Always keep readability in mind — a flipped label should still be easy to read.
- Combine label flipping with custom fonts, colors, and padding for better design consistency.
Common Use Cases for Flipping Y-Axis Labels
Over the years, I’ve used flipped Y-axis labels in many real-world Python projects, including:
- Financial charts – where inverted axes represent descending stock prices.
- Geological plots – where depth increases downward.
- Heatmaps or contour plots – where flipping the axis improves the visual flow.
- Dashboard layouts – to align multiple charts neatly.
Each of these cases benefits from the flexibility that Matplotlib provides for label customization.
When I first discovered how easy it was to flip the Y-axis label in Matplotlib, it completely changed how I designed my charts.
Now, I can make my Python visualizations not only accurate but also visually appealing and presentation-ready.
Whether you’re working on a business report, a data science project, or a research paper, flipping the Y-axis label can help you achieve a clean, professional look.
You may also like to read:
- Save a Matplotlib Graph as a PDF in Python
- Save Matplotlib Subplots to PDF in Python
- Save Multiple Pages to a PDF in Matplotlib
- Save Matplotlib Table as PDF in Python

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.