Book Image

Haskell Data Analysis Cookbook

By : Nishant Shukla
Book Image

Haskell Data Analysis Cookbook

By: Nishant Shukla

Overview of this book

Table of Contents (19 chapters)
Haskell Data Analysis Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
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. On...