2

I am trying to plot a series of functions on the same graphs. The code seems to run ok, but there is no picture coming coming out. just simply

<matplotlib.figure.Figure at 0xeafea58>

How can it be fixed?

Eric Enkele
  • 183
  • 1
  • 7
  • 17

1 Answers1

6

In the IPython console, the best way to make sure figures show up (without explicitly calling plt.show()) is to use %matplotlib mode. If matplotlib is installed correctly, it should automatically choose a suitable backend for your system.

For example:

In [1]: import matplotlib.pyplot as plt

In [2]: plt.plot([1, 2, 3])  # no plot shown!
Out[2]: [<matplotlib.lines.Line2D at 0x110eac898>]

In [3]: %matplotlib
Using matplotlib backend: MacOSX

In [4]: plt.plot([1, 2, 3])  # plot shown now
Out[4]: [<matplotlib.lines.Line2D at 0x112174400>]

enter image description here

The %matplotlib magic command only needs to be entered once per session.

jakevdp
  • 77,104
  • 11
  • 125
  • 160