Plotting Library

From Exterior Memory
Jump to: navigation, search

I wanted to find a plotting library for plotting charts (histograms, bar charts, pie charts). I like to either call from Python, or simply create a large data file and generate the plot using a command line tool. An interface for other programming languages, such as Java is a bonus, but no requirement. I wanted to be able to use the output in LaTeX articles, and on websites. So it should be able to output to PDF, SVG (vector) and PNG (bitmap). I currently have no desire to create interactive programs myself, though it is nice if I am able to interactively play with the output settings.

This article was written in December 2008. Given the volatile nature of this topic, expect that the content of this article is outdated after about two years time.

A good starting point is: Plotting and data visualization Tools with a (mostly) 2-D focus from the Topical Overview at SciPy. The lists contains many Python libraries that are useful for scientific computing with Python.

All of the packages bellow are good choices. Which one you choose really depends on your needs (interactive or batch processing, plotting or statistical analysis, etc.)

In the overview below, I've only looked at output formats PNG, PDF, SVG and terminal window (regardless if that was Aqua, Wx, GTK or X11). I've only looked at chart types Function Plot, Logarithmic Plot, Date/Time Plot, Bar Chart, Histogram, Scatter Plot, Pie Chart, Polar Plot, Map Projection, Contour Plot, Vector Plot, and 3D Plot.

Gnuplot

Python interface to Gnuplot

GNUplot is a very versatile plotting programming from UNIX. The Python interface is a very simple shell, and basically writes temporary files which are piped to gnuplot. Given this very basic shell, it may be just as simple to simply do writing to file and calling gnuplot yourself, instead of relying on this library. That is indeed be a simple but powerful solution.

Output formats: Terminal window, PNG, PDF, SVG, others
Chart types: Function Plot, Logarithmic Plot, Date/Time Plot, Bar Chart, Histogram, Scatter Plot, Polar Plot, Contour Plot, 3D Plot
Output quality: Below average
Pro: command line tool, commonly used
Con: poor Python integration, not very interactive, output quality below average, poor Unicode support, no pie charts

MatPlotLib

MatPlotLib is a python 2D plotting library.

Very slick looking plotting library for Python. Well written and easy learning curve. Simulates a Mathlab or Mathematica interface. The API is very interactive, and some API calls work with a global graphs instead of manipulating objects.

In order to get a full working scientific environment, about as powerfull as mathlab, you should install NumPy (fast multi-dimensional arrays, mathematics), SciPy (engineering modules), MatPlotLib (Plotting), and iPython (Interactive shell). The combination of these four is called PyLab.

Output formats: Terminal window, PNG, PDF, SVG, others
Chart types: Function Plot, Logarithmic Plot, Date/Time Plot, Bar Chart, Histogram, Scatter Plot, Pie Chart, Polar Plot, Map Projection, Contour Plot, Vector Plot, Embedded Image
Output quality: Very good
Pro: versatile, very good looking, interactive, Unicode support
Con: Python-only, no command line tool, no 3D plots

PLplot

PLplot

Cross-platform plotting library. Fine-grain control over the output. Slightly steaper learning curve than MatPlotLib, but still easier and more modern than GnuPlot. It seems great if

Output formats: Terminal window, PNG, PDF, SVG, others
Chart types: Function Plot, Logarithmic Plot, Date/Time Plot, Bar Chart, Histogram, Scatter Plot, Pie Chart, Polar Plot, Map Projection, Contour Plot, Vector Plot, 3D Plot, Embedded Image
Output quality: Good
Pro: good looking, Unicode support, multi-platform, interactive
Con: no command line tool

R

Python interface to R

R is an environment for Statistical Computing. It is not just a parser, but instead a whole programming environment. It is made for interactive statistical analysis as opposed to simply generating plots, and that shows in the output (which is rather text-based). Reminds me of statistical programs like ANOVA and SPSS.

Output formats: Terminal window, PNG, PDF
Charts types: Function Plot, Logarithmic Plot, Date/Time Plot, Bar Chart, Histogram, Scatter Plot, Pie Chart, Polar Plot, Map Projection, Contour Plot, Vector Plot, 3D Plot
Output quality: Below average
Pro: multi-platform, interactive, awesome for doing analysis
Con: not so great for making simple plots

PPGPLOT

PPGPLOT is a Python interface to PGPLOT.

PGPLOT is an older library, written in Fortran. PPGPLOT is a Python interface to PGPLOT, and was originally written in 1998. While it is reasonably fast, there are not so many output formats, and it relies on the older Python Numeric library instead of the newer numpy.

Output formats: PS, GIF only
Charts types: Function Plot, Bar Chart, Histogram, Scatter Plot, Contour Plot, Vector Plot, Embedded Image
Output quality: Below average
Pro: multi-platform. It works.
Con: few output formats, not interactive, no command line,

PyChart

PyChart is a good module to plot line, bar, and pie charts and scatter plots in Python. You have good control of text. Nothing more, nothing less.

Output formats: PNG, PS, PDF, SVG
Charts types: Function Plot, Logarithmic Plot, Bar Chart, Scatter Plot, Pie Chart, Polar Plot
Output quality: Average
Pro: It works, relative simple API
Con: not interactive, no command line tool, Python only

Chaco

Chaco is project similar to MatPlotLib: it is also highly interactive. The difference is that Chaco is faster, is mostly geared towards developers writing an application (e.g. it is easy to build a stand-along audio spectrum analyzer with Chaco). The downside is that the documentation is still a bit scattered (the examples are the best place to look), and it very geared towards displaying the graph on screen as oppossed to writing to file.

Output formats: Terminal window, PDF, SVG (preliminary)
Charts types: Function Plot, Logarithmic Plot, Bar Chart, Scatter Plot, Polar Plot, Contour Plot, Vector Plot, Embedded Image
Output quality: Very good
Pro: interactive, versatile, allows application development
Con: no command line, Python-only, not really suited for writing to file.