- 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 use 'extent' in matplotlib.pyplot.imshow?
To use extent in matplotlib imshow(), we can use extent [left, right, bottom, top].
Steps
- Create random data using numpy.
- Display the data as an image, i.e., on a 2D regular raster with data and extent [−1, 1, −1, 1] arguments.
- To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True data = np.random.rand(4, 4) plt.imshow(data, extent=[-1, 1, -1, 1]) plt.show()
Output
- Related Articles
- How to Use 'U' and 'L' formatters in Arduino?
- How to use wildcards like $ ('#name*'), $ ('#name%') in jQuery selectors?
- How to use the 'break' and 'next' statements in Ruby?
- How to use 'const' keyword in JavaScript?
- How to use the 'with' keyword in JavaScript?
- How to use the 'and' keyword in Ruby?
- How to properly use 'exist' function in MongoDB like in SQL?
- How can I use 'Not Like' operator in MongoDB?
- Use of 'weakMap.has()' method in JavaScript?
- Use of 'ClickAt ' selenium command.
- When should you use 'friend' in C++?
- How to unset 'sharex' or 'sharey' from two axes in Matplotlib?
- How to delete '' entry in MySQL?
- How to determine if a variable is 'undefined' or 'null'?
- MySQL query to select ENUM('M', 'F') as 'Male' or 'Female'?

Advertisements