- Trending Categories
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
- Related Articles
- Best way to display Seaborn/Matplotlib plots with a dark iPython Notebook profile
- Automatically run %matplotlib inline in IPython Notebook
- How do I get interactive plots again in Spyder/Ipython/matplotlib?
- Display Inline Working with CSS
- How to reuse plots in Matplotlib?
- Displaying rotatable 3D plots in IPython or Jupyter Notebook
- How to get multiple overlapping plots with independent scaling in Matplotlib?
- How to add annotations in Matplotlib Plots?
- Display Inline-Block Working with CSS
- Logscale plots with zero values in Matplotlib
- How to set the matplotlib figure default size in ipython notebook?
- What is the currently correct way to dynamically update plots in Jupyter/iPython?
- How to save Matplotlib 3d rotating plots?
- Matplotlib animation not working in IPython Notebook?
- How to make semilogx and semilogy plots in Matplotlib?

Advertisements