Jeff Hu
Jeff Hu

Reputation: 744

IPython: Does "%matplotlib inline" required before importing matplotlib?

I am using IPython. Got confused that the codes can't execute if I don't add

%matplotlib

before

import matplotlib.pyplot as plt

Could someone enlighten me by explaining why the magic function call in IPython is needed for matplotlib usage?

Upvotes: 0

Views: 203

Answers (1)

user2138038
user2138038

Reputation: 48

I believe it's needed because normally matplotlib opens additional windows for graphs using a default toolkit. The %inline lets you load graphs in the IPython notebook, instead of using an external toolkit.

Upvotes: 3

Related Questions