2

I am using jupyter and jupyter lab to analyze data.

In case of showing graph, I want to show all of graph in the last cell.

But jupyter and jupyter lab show graph right after setting plot code like

plt.scatter(regdata[0],regdata[1])

What I want to do is setting plots in above different cells and showing in the last cell.

m0nhawk
  • 22,980
  • 9
  • 45
  • 73
hiro
  • 21
  • 2
  • Possible duplicate of [prevent plot from showing in jupyter notebook](https://stackoverflow.com/questions/18717877/prevent-plot-from-showing-in-jupyter-notebook) – krassowski Feb 02 '19 at 03:34

1 Answers1

5

This is a duplicate of how to reuse plot in a next jupyter cell.

To summarise, you can just call the figure again in a later cell.

First cell

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

x = np.arange(0, 10)
y = x**2

fig, ax = plt.subplots()
ax.plot(x, y)
plt.close() # close figure to stop it showing in this cell.

To display this figure in a later cell you can just call the figure again:

Second cell

fig

This will display the figure

FChm
  • 2,515
  • 1
  • 17
  • 37