Confusion about '%matplotlib inline'

This is the first line in a script.

In Spyder, it is marked with a red cross. But the code runs successfully.

What does it mean?

Putting %matplotlib inline into a search engine gives a comprehensive explanation from Stack Overflow as the first result for me:

In short: it is not Python code (so Spyder doesn’t know anything about it). It is a special command for the IPython interpreter (also used by Jupyter notebooks), that controls how Matplotlib will be configured inside the notebook. It will only work in that environment.

1 Like