Book Image

Haskell Data Analysis cookbook

By : Nishant Shukla
Book Image

Haskell Data Analysis cookbook

By: Nishant Shukla

Overview of this book

Step-by-step recipes filled with practical code samples and engaging examples demonstrate Haskell in practice, and then the concepts behind the code. This book shows functional developers and analysts how to leverage their existing knowledge of Haskell specifically for high-quality data analysis. A good understanding of data sets and functional programming is assumed.
Table of Contents (14 chapters)
13
Index

Displaying a line graph using gnuplot

An Internet connection is typically unnecessary for plotting a graph. So, in this recipe, we will demonstrate how to make a line graph locally.

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 on its main website available at http://www.gnuplot.info.

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

$ cabal install easyplot

How to do it…

  1. Import the EasyPlot library as follows:
    import Graphics.EasyPlot
  2. Define a list of numbers to plot as follows:
    main = do
      let values = [4,5,16,15,14,13,13,17]
  3. Plot the chart on the X11 window as shown in the following code snippet. The X11 X Window System terminal is used by many Linux-based machines. If running on Windows, we should instead use the Windows terminal...