
Now, grid lines are going to be added to our output (you can see the produced output in Figure 4). Gnuplot> set ylabel "Setting the y-axis label" Gnuplot> set xlabel "x-axis: from -2*pi to +2*pi" Figure 3 shows the output that is produced by executing the following gnuplot commands: gnuplot> set title "An example for MacTech" The next thing that we would like to do is add our own text to the output. The new output can be seen in Figure 2.įigure 2: using -2*pi and +2*pi as our x-axis boundaries

Also note that the numerical value of pi is proximately 3.14. Please note that the AquaTerm output is updated automatically, so please do not close the AquaTerm application-this will make your life a lot easier. To do this, the following two commands must be given: gnuplot> set xrange Īs you can see, the "set xrange" command defines the graph boundaries, but the "replot" command is needed for Gnuplot to sketch the new output. Now, we will try to beautify the output-that is pretty basic and simplistic-and maybe add some text to it.įirst, if you remember your Math classes, it doesn't make sense to use -10 and +10 as our graph boundaries when dealing with trigonometric functions-it would be better to use -2*pi and +2*pi instead. You can see the generated output in Figure 1.įigure 1: drawing the sin(x)*cos(x) function This can be done after running gnuplot from a Terminal.app window: gnuplot> plot sin(x)*cos(x)Īfter pressing the return key, an AquaTerm output window will appear (AquaTerm was likely installed by your port manager, like MacPorts. You can do this by running the following command in the gnuplot command line. The first example that I will demonstrate you,will draw the sin(x)*cos(x) function. In my system, I had the following output: $ python -version You can find that info by running the following command from Terminal.app (or a similar application): $ gnuplot -VĪn analogous command will let you you find out the Python version that is installed into your Mac-Python will be used later on in this article. Some simple examplesįirst of all, let me review the version of Gnuplot that I am using. In my system, the gnuplot.pdf file (the official manual) is located inside the /opt/local/share/doc/gnuplot directory, but location will depend on your installation method. I will have to tell you that if you want to become an advanced Gnuplot user, you must start reading its official documentation. It also supports output in many different file formats including eps, fig, jpeg, LaTeX, METAFONT (invented by Donald Knuth the creator of TeX), pdf, png, postscript, etc.

It supports drawing using lines, points, vector fields, surfaces, boxes, and contours. Gnuplot can draw many types of plots in either 2D or 3D. It now supports web scripting and integration as a plotting engine for third-party applications like Octave. Gnuplot is a command line tool that was initially developed in order to allow scientists and students to visualize mathematical functions and data. The library is called py-gnuplot, and will be introduced in this article.

There is also a Python module for using Gnuplot inside of Python code. There are versions of Gnuplot for UNIX, IBM OS/2, MS Windows, DOS, Macintosh, VMS, Atari and many other platforms. Gnuplot is copyrighted but freely distributed. This article is going to present to you a very useful tool called Gnuplot. Educational Institution and Student DiscountsĬolumn Tag: math An Introduction to Gnuplot.
