This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Graphics & Multimedia

Creating graphs the old-fashioned way with Ploticus

By Bruce Byfield on March 28, 2008 (3:00:00 PM)

Share    Print    Comments   

Ploticus is a throwback to the days when Unix programs did one thing, and did it well, using a minimum of system resources. Its SourceForge.net page hints at this orientation by describing Ploticus as "non-interactive" software for "just-in-time graph generation." How useful it is depends on what you want to do, whether you use the settings that come with the program or define your own, and your willingness to master a lengthy -- if well-documented -- set of options.

Before using Ploticus, you should read its General FAQ to see it if will suit your needs. The FAQ explains that Ploticus produces only 2-D graphs and supports only basic statistical functions. Just as importantly, "it has scant support for mathematical formulas, scientific notations, or inline font or point size changes" and cannot be used with binary data. Unlike an application like OpenOffice.org, Ploticus makes no effort to be all things to all people -- in fact, the FAQ specifically disavows marketing graphics packages and "chartjunk" effects, stressing that features such as clip-art and gradient backgrounds "have been intentionally avoided." Knowing these limitations at the outset is important, because Ploticus takes time to learn, and you could waste your time if you start investigating the program with false expectations.

Using Ploticus

Ploticus' man page and on-site documentation consists almost entirely of examples, with no basic instructions. However, with a little study, you can determine that your first step must be to write a data file. This data file is a plain text file with a .dat extension, in which data is displayed in columns delimited by a space, tab, or comma. The information in the data file includes labels, actual graph values, and formatting options.

For example, the data for a pie chart of how you spend your days might read:

Employment,8,red
In transit,2,orange
Meals,1,green
Errands,1,purple
Household chores,2,yellow
Recreation & relaxation,2,blue
Sleep,8,gray

Once you have created the data file, your next step is to decide whether to use a prefab -- that is, one of the scripts that Ploticus supports by default -- or write your own script for the graph. Ploticus' documentation points out that you have more control with a script, but, against that benefit, you need to weigh the fact that you have to learn Ploticus' scripting conventions first. The scripting language is not difficult, assuming you have even a rudimentary knowledge of programming, but the time you spend learning it could easily negate Ploticus' time-saving ability to produce graphs on the fly unless you are a frequent user, or find an example that you can quickly customize.

The prefabs are more convenient, especially when you're first exploring the program, since they cover the most common range of graphs, and the online Prefab Handbook details what options you need to include with each prefab. Besides, you can do enough customizing using the command's extensive set of options that you might not even miss the power of a script. But be sure to take notes as you built your graph -- it could take a nearly photographic memory to recall all the options you need to get the results you want.

For instance, if you are using the pie prefab, your command must include the data option to specify the data file, and the values option to specify which column of the data file specifies the information displayed on the graph. You can use more options for such purposes as adding a legend, identifying the field in the data file that holds labels, and adjusting the font size of labels.

Having chosen the options that you want for your prefab, your next step is to choose any additional options for generating the graph. When you run the ploticus command, it reads options sequentially left to right, and options specified later overwrite earlier ones, so check for possible conflicts before you produce your graph.

Normally, Ploticus writes the graph to a .png file in the same directory as the data file, but you can change the graphics format to .gif, .jpeg, .svg, or .swf -- or simply display it on your screen -- and redirect the output. You can easily set the graph size, its fonts and font sizes, and its background color with the appropriate options.

With somewhat more difficulty, you can also tweak the positioning of the graph's legend or title, or crop it, either all around, or only on the sides specified. However, these options may require more trial and error than a person looking for quick output has time for.

Once you've chosen all your options, you are ready to generate your graph. As an example, the command for a relatively simple pie chart that uses the data file shown above is:

ploticus -prefab pie -png data=ploticustest.dat delim=tab values=2 labels=1 colorfld=3 title="Activity Hours" legend=yes name="Test Graph"

Note that the first option is the name of the prefab or the script. It is followed by the output format, then the name of the data file.

After all the setup, generation of the graph is almost an anticlimax, taking only a few seconds and returning no output to the command line except for detailed error messages that you can use to edit your commands. In the old Unix fashion, even a successfully created graph is not noted, requiring you to check the directory for the output file. The result, however, is a graph that you can show either directly from the desktop using a graphic view, or else easily import into a presentation or spreadsheet as required.

Conclusion

Ploticus is not for everyone. In particular, a dedicated desktop user with a phobia about the command line would balk at the sheer length of some of the commands necessary for fine control of the output. For such users, KChart is probably a better choice, since it also produces charts in independent files, but does so from a graphical interface.

At the same time, Ploticus is not nearly as formidable as it may seem during your first couple of experiments. The program really comes into its own if you are constantly generating the same kind of graph, and make the effort to put all the options that you are using into a script. If you are comfortable with the command line, you might even come to admire Ploticus' old-fashioned ingenuity and attention to detail.

Bruce Byfield is a computer journalist who writes regularly for Linux.com.

Share    Print    Comments   

Comments

on Creating graphs the old-fashioned way with Ploticus

Note: Comments are owned by the poster. We are not responsible for their content.

Ploticus or Porticus?

Posted by: Anonymous [ip: 24.20.9.183] on March 28, 2008 06:53 PM
Make up your mind, dude!

#

Re: Ploticus or Porticus?

Posted by: Joe Barr on March 28, 2008 08:08 PM
Oops. Corrected now, thanks.

#

Creating graphs the old-fashioned way with Ploticus

Posted by: Anonymous [ip: 91.84.13.8] on March 28, 2008 11:10 PM
As a (vastly superior) alternative, try R.

#

Re: Creating graphs the old-fashioned way with Ploticus

Posted by: Anonymous [ip: 83.226.140.220] on March 29, 2008 06:55 PM
Gnuplot does a pretty swell job too.

#

gnuplot licence :(

Posted by: Anonymous [ip: 86.53.48.59] on March 29, 2008 11:42 PM
Pity about gnuplot's licence. "Permission to modify the software is granted, but not the right to distribute the complete modified source code."

(gnuplot also brings back too many bad memories from undergraduate years past!)

#

PyX is another excellent alternative

Posted by: Stuart on March 29, 2008 11:39 PM
<a href="http://pyx.sf.net">PyX</a> is a lovely plotting library that I use for all my plotting. It makes wonderful plots and uses LaTeX for its typesetting so you can embed mathematical expressions into the plots, axes or titles. And it is built in python so you can use other python tools for data reading or processing while you are at it. I have a few "swiss army scripts" that do generic plots for me and then tailor them to make the publication quality plots that I routinely need.

See also <a href="http://lists.debian.org/debian-science/2005/10/msg00053.html">this thread</a> on the debian-science mailing list for a discussion on the merits of a number of other plotting packages:

#

were did the bull in the china closet go?

Posted by: Anonymous [ip: 66.122.165.196] on March 31, 2008 12:57 AM
_ ?

#

Creating graphs the old-fashioned way with Ploticus

Posted by: Anonymous [ip: 195.5.138.130] on March 31, 2008 03:00 PM
Why didn't you included at least one picture?

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya