-2
import matplotlib.pyplot as plt

%matplotlib inline

fig=plt.figure()

plt.show()

Output is:

matplotlib.figure.Figure at 0x536ea70

I want to see empty plot and i was going through a pycon tutorial the same code produced a empty plot.

ramakrishnareddy
  • 481
  • 1
  • 5
  • 9

1 Answers1

0

IPython will not generate any output for figures that do not contain an axes.

If you add an axes to your figure, the figure will show fine.

%matplotlib inline
import matplotlib.pyplot as plt

fig, ax = plt.subplots()

plt.show()

or

%matplotlib inline
import matplotlib.pyplot as plt

plt.gca()

plt.show()

enter image description here

If you then remove the axes, it will again show the returned python string again.

enter image description here

The solution to show a completely empty figure with the inline backend is hence to add an axes but then turn it invisible.

%matplotlib inline
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.set_visible(False)

plt.show()

enter image description here

ImportanceOfBeingErnest
  • 251,038
  • 37
  • 461
  • 518