Skip to content Skip to sidebar Skip to footer

Python And Matplotlib - Simple Chart Not Showing, No Errors

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 err

Solution 1:

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 installedimport 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 osprintos.path.join(matplotlib.get_configdir(), 'matplotlibrc')

You should be looking for something like backend: Agg.

Solution 2:

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

Post a Comment for "Python And Matplotlib - Simple Chart Not Showing, No Errors"