3

I'm using the Jupyter notebook for python 2 to write code. I change the backend of matplotlib in one notebook with the following code and get a GUI.

import matplotlib
matplotlib.use('TkAgg')

When I create a new notebook with Jupyter, every time I plot a graph, a get a pop-up window. What do I need to do to get a the plotted graph within the notebook? I tried the following backend arguments:

matplotlib.use('Agg'/GTKAgg/Qt4Agg/WXAgg)

Here's my code of plot a graph:

import matplotlib
matplotlib.use('GTKAgg')
import matplotlib.pyplot as plt
import pandas as pd

dataframe = pd.DataFrame('ex0.csv')
dataframe.plot()
plt.show()
Kann7
  • 63
  • 1
  • 4
  • I tried all the following in the .use argument, but still can't get the graph plot within the notebook : u'pgf', u'ps', u'Qt4Agg', u'GTK', u'GTKAgg', u'nbAgg', u'agg', u'cairo', u'MacOSX', u'GTKCairo', u'Qt5Agg', u'template', u'WXAgg', u'TkAgg', u'GTK3Cairo', u'GTK3Agg', u'svg', u'WebAgg', u'pdf', u'gdk', u'WX' – Kann7 Aug 17 '17 at 01:41
  • 1
    To get the plot on the notebook you need to declare `%matplotlib inline` before the plotting command. – swatchai Aug 17 '17 at 01:53
  • @swatchai Problem solved. Thanks! – Kann7 Aug 17 '17 at 02:24

0 Answers0