Using %matplotlib notebook after %matplotlib inline in Jupyter Notebook doesn’t work

You just have the wrong order of your commands. A backend should be set before importing pyplot in jupyter. Or in other words, after changing the backend, pyplot needs to be imported again. Therefore call %matplotlib … prior to importing pyplot. In first cell: %matplotlib inline import matplotlib.pyplot as plt plt.plot([1,1.6,3]) In second cell: %matplotlib … Read more

Retrieve XY data from matplotlib figure [duplicate]

This works: In [1]: import matplotlib.pyplot as plt In [2]: plt.plot([1,2,3],[4,5,6]) Out[2]: [<matplotlib.lines.Line2D at 0x30b2b10>] In [3]: ax = plt.gca() # get axis handle In [4]: line = ax.lines[0] # get the first line, there might be more In [5]: line.get_xdata() Out[5]: array([1, 2, 3]) In [6]: line.get_ydata() Out[6]: array([4, 5, 6]) In [7]: line.get_xydata() … Read more