Data Visualization

 

Generating a visual representation is often the best way to understand large data sets, but standard tools such as gnuplot often fall short. This article shows how to use Perl/Tk, the standard GUI toolkit for Perl, to quickly build custom plotting and graphing tools

The human eye is incredibly good at recognizing complex behavior and spotting trends and patterns in visually displayed data. If any dataset is larger than about a dozen points, a graph is helpful; if the dataset exceeds a few thousand points, a graph becomes a necessity.

For simple x-y plots, gnuplot is often the first choice. For more complicated problems you can use xmgrace and other plotting tools. However, most simple curve plotters are insufficient for plotting two-dimensional data or for exerting detailed control over a complicated graph. Examples of complicated graphs include specialized bar-and-whiskers plots, time-series with sophisticated error bars, color encodings and density plots, and many other possibilities.

This is where Perl/Tk shines. Chances are, you're already using Perl for data manipulation and extraction. Perl/Tk provides Perl bindings for the Tk GUI toolset and is possibly one of the easiest-to-use widget sets around.

In this article, I'm not as interested in the actual user-interface parts of Perl/Tk (such as checkboxes and drop-down menus) as I am in its graphing capabilities.

Being a GUI-toolkit, Perl/Tk provides an additional facility, which is absent from other graphing extensions to Perl (such as the excellent GD package): namely, the ability for animations and interactive data exploration. I'll show you applications for this in the examples below.