matplotlib library provides another alternative for generating charts from Python. It can be found on the Python Package Index site, http://pypi.python.org/pypi/matplotlib. The version of
matplotlib used in this chapter is 0.98.3.
matplotlib, our application cannot simply construct a URL and push the task of generating and serving the image data off to another host. Instead, we need to write a view that will generate and serve the image data. After some investigation of the
matplotlib APIs, an initial implementation (in
survey/views.py) might be:
from django.http import HttpResponse from survey.models import Question from matplotlib.figure import Figure from matplotlib.backends.backend_agg import FigureCanvasAgg ...