1

I was looking at a few tutorials about plotting inline with jupyter notebook and they all say to use the %matplotlib inline, but when I run code normally from my notebook and call plot.show() the chart shows automatically without using magic. I'm am running jupyter from the anaconda package so not sure if that makes a difference.

Is it still necessary to use the inline magic for matplotlib?

onetap
  • 455
  • 1
  • 5
  • 8
  • I asked a [similar question](https://stackoverflow.com/questions/54329901/behavior-of-matplotlib-inline-plots-in-jupyter-notebook-based-on-the-cell-conten) quite a while ago but did not get any answer yet. You can also see a similar post [here](https://stackoverflow.com/questions/50992742/use-of-the-magic-function-matplotlib-inline) – Sheldore Jul 18 '19 at 14:13

3 Answers3

0

The point of that particular magic is to avoid the need for plt.show(), and show the plot directly on plt.plot(...).

If you don't mind using .show(), you don't need %matplotlib inline. I think it's more convenient to use it.

Itamar Mushkin
  • 2,803
  • 2
  • 16
  • 32
  • I disagree. Read the **Case 1** in my first linked post in the comment above. In JuPyTer notebook, the plots appear even without using `%matplotlib inline` and `plt.show()` – Sheldore Jul 18 '19 at 14:14
  • Maybe we're running some different configurations or something, but your case 1 isn't working the same way on my end. Maybe you alreasy set the default backend to be inline (like in ImportanceOfBeingErnest's answer)? – Itamar Mushkin Jul 21 '19 at 05:17
0

It's pretty simple: If the inline backend is selected by default, there is no need to activate it again.

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
-1

If you use %matplotlib inline, the Jupyter notebook will save the graph to the notebook. This is not the case for plt.show() which just gives you a temporary visualization of the graph.

Jarett LeVan
  • 389
  • 1
  • 10