Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 20
    Your second code misses the whole point of using %matplotlib inline. The whole point is that now you don't need to use plt.show() which you are still using in the second code. One more interesting fact, in your second code, the figure will still appear in the jupyter notebook even if you don't use % matplotlib inline and just use plt.show(). Read my following question here which is even today unanswered. Commented Jul 17, 2020 at 9:26
  • 1
    Yeah, there are certain bugs in the software we use. I usually like to write the clear commands. This means plt.show() should exist. The magic of %matplotlib inline should also be there even though it may be set somewhere by default. Commented Jul 17, 2020 at 10:11
  • 1
    But I really do not see why you want to use plt.show() in your jupyter notebook when you are using matplotlib inline explicitly. Especially, when you are answering a question like this in the context of jupyter notebook Commented Jul 17, 2020 at 12:29
  • 1
    I personally like to have a command to control if something should appear or not. I hate being implicit or partial. Imagine the case that someone in error sets plt.close() without setting plt.show(). You restart the notebook and you see nothing shows up. So I would still set plt.show(), it cannot hurt. Commented Jul 17, 2020 at 13:26
  • 7
    Interesting. Because I use Jupyter Notebook and, with or without %matplotlib inline, the output is always the second case. Windows never pop out. Commented Mar 13, 2021 at 0:17