HOME/Articles/

matplotlib example python-matplotlib-on-ubuntu (snippet)

Article Outline

Python matplotlib example 'python-matplotlib-on-ubuntu'

Modules used in program:

  • import matplotlib.pyplot as plt
  • import matplotlib

python python-matplotlib-on-ubuntu

Python matplotlib example: python-matplotlib-on-ubuntu

# Debian/Ubuntu: sudo apt-get install python-matplotlib
# http://stackoverflow.com/questions/2801882/generating-a-png-with-matplotlib-when-display-is-undefined

import matplotlib
matplotlib.use('Agg') # Must be called before import matplotlib.pyplot
import matplotlib.pyplot as plt