0

Below is about as simple can get with matplotlib.

import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
print 'done'

When I run, I get no errors, no charts, and goes straight to printing 'done'.

I installed on ubuntu 10.04 using easy_install.

5
  • How are you running the code? In a script or in an interpreter? Commented Jul 20, 2012 at 19:24
  • The code actually displays a plot for me either way. Commented Jul 20, 2012 at 19:25
  • I am Running in eclipse. Commented Jul 20, 2012 at 19:29
  • Well you could try running the code in the python interpreter, or directly as a script. If that doesn't work, you'll know there's something wrong with your installation. Commented Jul 20, 2012 at 19:32
  • tried that...same issue. Commented Jul 20, 2012 at 19:38

2 Answers 2

3

Your backend is probably a non-interactive backend (such as 'Agg'). Have you got the backend setup in your matplotlibrc file?

Try:

import matplotlib
matplotlib.use('TkAgg') # or some other backend which you have installed

import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
print 'done'

You can find the location of your matplotlib rc file with:

import matplotlib
import os

print os.path.join(matplotlib.get_configdir(), 'matplotlibrc')

You should be looking for something like backend: Agg.

Sign up to request clarification or add additional context in comments.

7 Comments

I get this error. import _tkagg ImportError: No module named _tkagg
Maybe you don't have a TkInter installation. Do you have any other GUI toolkits available? Gtk, Qt4, WxPython etc.?
yup..sudo apt-get install python-tk
If you've just added Tk then it might be worth re-installing/building matplotlib so that it can build the appropriate C library.
Just did that...no go. Even when so far as to reboot.
|
0

The backends are probably not installed; try installing the Ubuntu package python-matplotlib. If you're in ipython, try running the cell %matplotlib inline.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.