- 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
What does axes.flat in Matplotlib do?
Axes.flat means a 1D iterator over the array. Let's take an example to see how to use axes.flat.
Steps
Set the figure size and adjust the padding between and around the subplots.
Create a figure and a set of subplots using subplots() method.
Create x and y data points using numpy.
Use axes.flat and iterate all the axes (step 2).
Plot x and y data points using plot() method.
To display the figure, use show() method.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, axes = plt.subplots(nrows=2, ncols=3) x = np.random.rand(10) y = np.random.rand(10) for _, ax in enumerate(axes.flat): ax.plot(x, y) plt.show()
Output
- Related Articles
- What does .shape[] do in “for i in range(Y.shape[0])” using Matplotlib?
- What does "print >>" do in python?
- What does [::-1] do in Python?
- What does Tensor.detach() do in PyTorch?
- What does backward() do in PyTorch?
- What Does the // Operator Do?
- What does the &= operator do in Python?
- What does select @@identity do in MySQL?
- What does method time.tzset() do in Python?
- What does jQuery.serialize() method do in jQuery?
- What does % do to strings in Python?
- What does reload() function do in Python?
- What does raw_input() function do in python?
- What does input() function do in python?
- What does print() function do in Python?

Advertisements