Install Gnuplot in Ubuntu 22.04

Gnuplot is a command-line utility, which is mainly used to make 2D and 3D graphs. So, it is a great tool to plot mathematical functions. Apart from that, we can also graphically analyze data through it. Furthermore, we can get the output on a terminal, to various supported devices and in form of numerous file formats which includes, PDF, JPEG and PNG among others. In this article, we cover how to install Gnuplot in Ubuntu 22.04 release.

In the Additional Info section, we cover how to plot a simple graph. But, for now the installation steps.

Note: Following operations require you to have superuser privileges. In case you don’t have one then, we advise you to contact your System Administrator for assistance.

Install Gnuplot in Ubuntu 22.04

The package, gnuplot, is available through standard Ubuntu repository. Therefore, all we need to do is – update the repository first. And, thereafter install the package through the following commands. Hence, open a terminal and issue –

sudo apt update
sudo apt install gnuplot

That is pretty much everything we need to do to install Gnuplot.

In conclusion, we have covered how to install Gnuplot in Ubuntu 22.04 release here.

Additional Info –

Since, it is a command-line utility. Therefore, open a terminal and issue the following to launch it –


It starts with GNUPLOT, version number and other details. We discuss here couple of examples, first one is simple mathematical function and other one contains some data.

Example I. We start with plotting graphs of sin(x) and cos(x) –

gnuplot> set title "Sine function"; plot sin(x)
gnuplot> set title "Cosine function"; plot cos(x)

It would open a window for each of these function graphs. At the top left, we can either export the output to SVG, PDF or an Image. Or, simply just copy it to Clipboard and paste it somewhere else.

Example II. In addition to, we can also provide a range and do some calculations on it –

gnuplot> set title "Range Plot"; set xrange [-20:30]; set yrange [-5:5]; plot (x/8.5), (x/-12.5)

To exit from the prompt, press Ctrl+D.