ascii_graph
ascii_graph is a module for producing ASCII graphs. It is used
via plot.pl. This is a recent development
(20041209) which is proving very useful for generic 'show me a
quick graph of that' requirements.
The output from plot.pl is either plaintext, HTML
markup text or colour terminal-encoded (UNIX colour terminals
only at time of writing).
The source is here
The documentation is below
> akelly\plot.pl -h
akelly\plot.pl by allankelly@if.com Wed Nov 10 08:44:32 GMT 2004
Usage:
H:\Allan Kelly\code\perl\ascii_graph\akelly\plot.pl <opts> datafile
Options:
-rows data is in rows
-cols data is in cols
-header dataset names as 1st data item
-title <title> graph title (default: datafile name if supplied)
-width <chars> graph width
-height <chars> graph height
-xlabel <name> x-axis label (default: x dataset header if supplied)
-ylabel <name> y-ayis label (default: y dataset header if 1 y dataset)
-legend <list> legend (default: y dataset headers if supplied)
-cut <rows or cols> datasets to draw NB 1st is 0 (default: all supplied datasets)
-cut <headers> datasets to draw selected by header name
Supply multiple -cut args for multiple graphs from the same data
eg H:\Allan Kelly\code\perl\ascii_graph\akelly\plot.pl -cut 0,3,4 -cut 0,1,2
-grid <char> character to use for 'grid' - use a space to have none
-datamark <char list> characters to use for data markers
-datacolor <color list> use colours for data markers (for color terminals)
Allowed colours: black red green yellow blue magenta cyan white
Also, for the HTML modes any #RRGGBB colours are OK.
Note that specifying any HTML option sets the default list
of colours, which may be over-ridden.
-html HTML output. Same as usual, but -datacolor uses <font> tags.
-html_black HTML output. As -html, but black background/white foreground.
-html_pre HTML output, wrapped in <pre> tags so output is small
but lines can't be wrapped (eg for email, see -email option).
Can be combined with -html_black.
-no_y_zero don't draw the y==0 axis. This has 2 implications:
1. Where the dataset has +ve and -ve values.
- we simply don't draw the y==0 axis line.
2. Where the dataset is all +ve or all -ve.
- we scale the y-axis to contain the dataset only.
-y_log_scale Use log y-axis
-email Max email line length is 998 chars (RFC 2822) so split lines.
NOTE: This is only effective for HTML output as for
other formats it will destroy the layout. However it's
implemented for all formats, so that at least your email
will arrive intact.
-h Print this message and exit.
Here's a very simple sample output.
First put some sin and cos data into a file
> perl -e "print qq(VAL\tSIN\tCOS\n);for(1..20){print $_,qq(\t),sin $_,qq(\t),cos $_,qq(\n)}" > sincos.csv
Now call plot.pl with some options and the sincos data as input.
> akelly\plot.pl -header -width 50 -height 10 -grid " " -datamark "o,o" -html_pre sincos.csv > plot_sincos.html
sincos.csv
+--------------------------------------------------+SIN o
1.19| |COS o
0.99| o |
0.79|o o o o o o o o |
0.59| o o o |
0.39|o o o o |
0.19| o |
0.00| ----o-------------------o------o------------o-----|
-0.20| o |
-0.40| o o o |
-0.60| o o o |
-0.80| o o o |
-1.00| o o o o o o o |
+--------------------------------------------------+
| | | | | | | | | | | | | | | | | | | |
1 2 3 4 5 6 7 8 9 10 1112 1314 1516 1718 1920
VAL
|
|
|