For solving this, you can use different back-end:

import matplotlib  
matplotlib.use('TkAgg')  
import matplotlib.pyplot as plt  

Other GUI backends:

  • TkAgg
  • WX
  • QTAgg
  • QT4Agg

Run your code using: C-u C-c C-c