See the comment by nom-mon-ir:
import matplotlib.pyplot as plt
instead of import matplotlib.pyplot as plt or using a new ipython version