Displaying a scatter plot of two-dimensional points

This recipe covers a quick and easy way to visualize a list of 2D points as scattered dots within an image.

Getting ready

The library used in this recipe uses gnuplot to render the graph. We should first install gnuplot.

On Debian-based systems such as Ubuntu, we can install it using apt-get as follows:

$ sudo apt-get install gnuplot-x11

The official place to download gnuplot is from its main website, http://www.gnuplot.info.

After gnuplot is set up, install the easyplot Haskell library using cabal as follows:

$ cabal install easyplot

Also, install a helper CSV package as follows:

$ cabal install csv

Also, create two comma-separated files, input1.csv and input2.csv, which represent two separate sets ...

Get Haskell Data Analysis Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.