IPython: how to show the same plot in different cells?

I'm still new to IPython Notebooks, Jupyter, and Python in general.

I am creating a scatter chart in a Jupyter laptop using the following code:

import numpy as np
import matplotlib.pyplot as plt

n = 1024
X = np.random.normal(0, 1, n)
Y = np.random.normal(0, 1, n)
plt.axes([0.025, 0.025, 0.95, 0.95])
plt.scatter(X, Y, s=50)

plt.show()

My question is, how can I get a reference to the plot object so that I can use it in another cell later in the laptop? In addition, I may need to change the schedule before showing it again.

In addition, I have %matplotlib inlinethe top of my laptop.

The following is information about my environment:

  • Python: 3.5.2 64bit [MSC v.1900 64 bit (AMD64)]
  • IPython: 4.2.0
  • numpy: 1.11.1
  • scipy: 0.17.1
  • matplotlib: 1.5.1
  • sympy: 1.0
  • : Windows 7 6.1.7601 SP1
+4
1

- matplotlib - matplotlib.figure; Figure, .

  • - fig = plt.figure()
  • - ax = fig.add_axes([0.025, 0.025, 0.95, 0.95])
  • - ax.plot(X, Y)
0

Source: https://habr.com/ru/post/1650088/


All Articles