- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- 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
Change values on matplotlib imshow() graph axis
First, we can initialize an array matrix and pass it into the imshow method that can help to get the image for the given matrix.
Create a 2D Array i.e., img.
Using imshow() method, display the data as an image, i.e., on a 2D regular raster.
Use plt.show() method to show the figure.
import matplotlib.pyplot as plt img = [[1, 2, 4, 5, 6, 7], [11, 12, 14, 15, 16, 17], [101, 12, 41, 51, 61, 71], [111, 121, 141, 151, 161, 171]] plt.imshow(img, extent=[0, 5, 0, 5]) plt.show()
- Related Articles
- How to specify values on Y-axis in Python Matplotlib?
- How to plot an image with non-linear Y-axis with Matplotlib using imshow?
- How to change the scale of imshow in matplotlib without stretching the image?
- Hide axis values but keep axis tick labels in matplotlib
- How to plot multiple Pandas columns on the Y-axis of a line graph (Matplotlib)?
- How to apply a mask on the matrix in Matplotlib imshow?
- How to force Matplotlib to show the values on X-axis as integers?
- How to represent all values of X-axis or Y-axis on the graph in R using ggplot2 package?
- Updating the X-axis values using Matplotlib animation
- How can I plot NaN values as a special color with imshow in Matplotlib?
- Automatically setting Y-axis limits for a bar graph using Matplotlib
- How to shift a graph along the X-axis in matplotlib?
- Adjusting gridlines and ticks in Matplotlib imshow
- How to change the range of the X-axis and Y-axis in Matplotlib?
- How to set X-axis values in Matplotlib Python?