Gnuplot - Not for herding cows, great for graphs


Updated: August 30, 2014

A great way to impress people is to show them a nice graph. Very few individuals are blessed with the ability to interpret numbers in a meaningful way, a-la Rain Man style. While they may see hidden patterns in a table of integers, most people struggle making those kind of connections, which is why they resort to images.

But there are images, and then, there are images. Nothing invokes disdain better than a default coloring scheme used in Excel generated graphs. On the other hand, the tight Matlab plots always cause a nice stir of professionalism, even when there's none to be found. So let me teach you about a program that will up your salary: gnuplot.

Fancy graph

Gnuplot turf of duty

Ah, innuendos, my favorite hobby. Gnuplot is a simple, no-nonsense software for generating plots from data sets, using command line. Yup, no fancy frontends to help you create your presentations, just a bunch of nifty commands toward that Bob's your uncle moment. So what gives? Let's play with gnuplot.

Now, do note I will not be doing a Class 101 plus info plus man pages plus Internet here. Not the purpose of this article. If you want to know how to create Mobius ring graphs, then you will have to sweat those search engines a little. But if you are interested in a primer toward a more elegant, more efficient way of generating graphs, here you go.

Gnuplot expects data files to be similar to Matlab DAT files, space-delimited columns of numbers that you intend to use. Then, just load a file and plot the data points as you see fit. For example, the basic plot using the first and second columns inside the file:

gnuplot> plot "data.txt" 1 2 with lines

First graph

Next, you can start playing with the plot attributes - change the axis scale, range and titles, change the font, change the color, set the legend on and off, adjust the graph margins and size, and pretty much anything you can think of.

Gnuplot commands

Gnuplot behaves like any command line interpreter. A shell, if you will, with command history and all that, plus it lets you script your commands, so you can create automated tasks for repetitious actions, saving a lot of time. And let's say nothing of that professional feel oozing off the graphs.

Advanced graph

After a while, you may start really getting wild with your work. Gnuplot even lets you export transparent PNG images, where you set the size and shape and the color set. You will spend a little time trying to find your way around, but after a while, you will get in the groove, and your efficiency will spike. Just remember that every command is well spent, because you can just copy & paste it into the next graph, saving time.

Fancy graph

Conclusion

I am by no means a gnuplot guru. But this short article slash demo should convince you to give it a try. Overall, it's very similar to Matlab, so if you know your way around there, learning gnuplot won't be a very difficult task for you.

If you're not familiar with the Matlab syntax, and have never generated graphs from the command line, you might find the whole concept rather alien. But do not be afraid. Gnuplot is a natural extension of using Linux, which is a good thing for you. So if you're okay with that one thing, you will be fine with both. So much for using Linux, right.

Anyhow, Gnuplot is a very handy little program with a lot of power and built-in efficiency, waiting for the enterpreneuring nerd to unleash its spells. In addition to making you more comfortable with the command line, it will also probably generate extra revenue in the long run, because everyone likes pretty pictures. And with this, my sales pitch ends.

Cheers.

RSS Feed icon

del.icio.us del.icio.us stumbleupon stumble digg digg reddit reddit slashdot slashdot



Advertise!

Would you like to advertise your product/site on Dedoimedo?

Read more

Donate to Dedoimedo!

Do you want to
help me take early retirement? How about donating
some dinero to
Dedoimedo?

Read more

Donate