- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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 display print statements interlaced with Matplotlib plots inline in iPython?
To display print statements interlaced with matplotlib plots inline in iPython, we can take the following steps.
Steps
Import pyplot from matplotlib.
Make a list of data for hist plots.
Initialize a variable "i" to use in print statement.
Iterate the list of data (Step 2).
Create a figure and a set of subplots using subplots() method.
Place print statement.
Plot the histogram using hist() method.
Increase "i" by 1.
Example
In [1]: from matplotlib import pyplot as plt In [2]: myData = [[7, 8, 1], [2, 5, 2]] In [3]: i = 0 In [4]: for data in myData: ...: fig, ax = plt.subplots() ...: print("data number i =", i) ...: ax.hist(data) ...: i = i + 1 ...: data number i = 0 data number i = 1 In [5]:
Output
data number i = 0 data number i = 1
Advertisements