- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to plot an image with non-linear Y-axis with Matplotlib using imshow?
To plot an image with non-linear Y-axis with matplotlib using imshow() method, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Add a subplot to the current figure.
- Set nonlinear Y-axis ticks.
- Create random data points using numpy.
- Display data as an image, i.e., on a 2D regular raster, with data.
- To display the figure, use show() method.
Example
import matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True ax = plt.subplot(111) ax.yaxis.set_ticks([0, 2, 4, 8]) data = np.random.randn(5, 5) plt.imshow(data, cmap='copper') plt.show()
Output
- Related Articles
- Matplotlib – How to set xticks and yticks with imshow plot?
- How to plot data into imshow() with custom colormap in Matplotlib?
- Plot a histogram with Y-axis as percentage in Matplotlib
- How to exponentially scale the Y axis with matplotlib?
- How to plot two Pandas time series on the same plot with legends and secondary Y-axis in Matplotlib?
- How to plot on secondary Y-Axis with Python Plotly?
- Plotting an imshow() image in 3d in Matplotlib
- How can I plot NaN values as a special color with imshow in Matplotlib?
- How to crop an image along the Y-axis using FabricJS?
- How to plot 1D data at a given Y-value with PyLab using Matplotlib?
- How to create a bar plot using ggplot2 with percentage on Y-axis in R?
- How to draw a log-normalized imshow plot with a colorbar representing the raw data in Matplotlib?
- Change values on matplotlib imshow() graph axis
- How to create a surface plot from a greyscale image with Matplotlib?
- How to hide axes but keep axis-labels in 3D Plot with Matplotlib?

Advertisements