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…
- Import the
EasyPlot
library as follows:import Graphics.EasyPlot
- Define a list of numbers to plot as follows:
main = do let ...
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.