I'm running this in the current version of Jupyter.
One of my cells contains the following.
import matplotlib.pyplot as plt
def main():
a_list = list(range(20))
plt.plot(a_list)
plt.show()
main()
When I run kernel > Restart & Run All the only output I get is a plot figure: <matplotlib.figure.Figure at 0x1bd35aa7a20> .
When I run the cell directly with the Run button, I get the expected plot.
When I move main() to its own cell and then run kernel > Restart & Run All I get the expected plot.
I would appreciate help in understanding what's going on.
%matplotlib inlineat the beginning of your notebook and then runkernel > Restart & Run All, do you get the expected plot? (If so, then here is a way to automatically run%matplotlib inlinewhenever IPython notebook is started.)%matplotlib inlinelets the initial example work as expected. But still, what's going on? Why is that necessary (sometimes)? And how would someone know to do that?