我是matplotlib的新用户,我的平台是Ubuntu 10.04 Python 2.6.5
这是我的代码
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
plt.plot([1,2,3])
Run Code Online (Sandbox Code Playgroud)
错误是:
/usr/local/lib/python2.6/dist-packages/matplotlib/backends/__init__.py:41: UserWarning:
Your currently selected backend, 'agg' does not support show().
Please select a GUI backend in your matplotlibrc file ('/usr/local/lib/python2.6/dist-packages/matplotlib/mpl-data/matplotlibrc')
or with matplotlib.use()
(backend, matplotlib.matplotlib_fname()))
Run Code Online (Sandbox Code Playgroud)
apt-get install libagg但它不起作用.python-gtk2-dev包,但仍然出现错误.这是错误:
>>> matplotlib.use('GTK')
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/matplotlib/pyplot.py", line 95, in <module>
new_figure_manager, draw_if_interactive, show = …Run Code Online (Sandbox Code Playgroud) import matplotlib.pyplot as pl
%matplot inline
def learning_curves(X_train, y_train, X_test, y_test):
""" Calculates the performance of several models with varying sizes of training data.
The learning and testing error rates for each model are then plotted. """
print ("Creating learning curve graphs for max_depths of 1, 3, 6, and 10. . .")
# Create the figure window
fig = pl.figure(figsize=(10,8))
# We will vary the training set size so that we have 50 different sizes
sizes = np.rint(np.linspace(1, len(X_train), 50)).astype(int) …Run Code Online (Sandbox Code Playgroud)