
| Gplot simplifies gnuplot graph creation |
| 摘自: linux.com 被阅读次数: 100 |
由 yangyi 于 2008-04-25 19:06:12 提供 |
Gnuplot can generate sophisticated graphs and output them in vector or bitmap image formats. It can produce many graph types, and you can customize the way the output will look to a great extent. But the customizability of gnuplot can work against it when all you want a simple line graph comparing two series of data points. In those cases, gplot lets you use gnuplot to create simple graphs using more semantic options to customize the appearance of common graph objects. Gplot's main dependencies, gnuplot and Perl, should be packaged by your distribution. As gplot is a Perl script, installation simply involves copying the gplot.pl file from the distribution tarball into your path to a location such as /usr/local/bin. You need one or more sets of input data in order to generate a graph image. By default each graph line comes from its own input file. The data in each input file is in the form of a single coordinate per line in the format "X Y," where the ordinates are separated by white space. If your input only contains the Y values and you are happy to have the X ordinate start at zero and increment by one for each value, then you can use the The below commands take an input data series and create a graph (shown below) in JPEG format representing this series. I have broken the command line after the title because the next two options (name and onecolumn) relate to the data file t1.data. Options which relate to a particular data file will use the data from the next data file path given on the command line. For example, if there were a second data file, I could repeat the name and onecolumn options after t1.data but before citing the second data file's path to create two lines in the output graph, one for each data file.
You can change the bland X and Y axis labels using the Since gplot uses gnuplot to create graphs, you might wish to get access to the data that is fed to gnuplot. The If you wish to customize the gnuplot output that gplot generates, you might consider changing the input template gnuplot file that gplot uses and passing Values in the template gnuplot file that are contained between % characters are substituted with their values when gplot is executed. The below example places the value of the
One might hope that any command-line parameters, or those starting with a given prefix, could be substituted in this manner. Gplot will generate an error if you attempt to pass a new command-line option for template substitution like this. Adding options for use in template substitution is not difficult though. The gplot.pl script needs two slight modifications: change
With the addition of the foo command-line option, the template can include %FOO% wherever you wish:
The ability to customize gnuplot template files with gplot gives you the ability to produce some fairly advanced graphs using templates to specialize how things appear while retaining the simple interface of gplot. The following example uses three different data series which are per-month statistics. Since I'm using time-related data I can take advantage of the
Gplot can also generate vector format output using At times you can run up against the boundaries of gplot and have to write gnuplot directives in a gplot template file to achieve the desired result, but the ability to substitute variables in the gnuplot template file should allow you to handle many graphing needs using gplot. Gplot makes creating simple graphs a simple task, and still lets you tap into anything that gnuplot can do if the need arises. Ben Martin has been working on filesystems for more than 10 years. He completed his Ph.D. and now offers consulting services focused on libferris, filesystems, and search solutions. Original link: http://www.linux.com/feature/127... |