Saturday, December 29, 2018

Curve Plotting with C++

In this article, some of the tools for plotting curves with C++ will be discussed with examples. They are


Gnuplot

Gnuplot can be installed on Ubuntu using the following commands.

$ sudo apt update
$ sudo apt install gnuplot


Entering the following command starts Gnuplot.

$ gnuplot


Information such as version number for Gnuplot will be displayed and you will be at the command prompt of gnuplot. As a testing, we will plot sin(x) and cos2(x) will be plotted on it again. Thereafter, the plots as illustrated in Figure. 1 should appear [Mig18]. You can enter 'q' to quit Gnuplot.

> plot sin(x)
> replot cos(x)**2
> q



Figure 1. Plotting sin(x) and cos2(x) to test gnuplot.