-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathplot
More file actions
executable file
·141 lines (119 loc) · 3.31 KB
/
plot
File metadata and controls
executable file
·141 lines (119 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/perl -w
# Author: T. Religa
# Licence: GPL
# Date: 2003-05-07
use Getopt::Std;
getopts('x:y:t:e:r:o:s:c:p:l:m:3adghv', \%opts);
&usage() if $opts{"h"};
$verbose = $opts{"v"} || 0;
$xlabel = $opts{"x"} || "";
$ylabel = $opts{"y"} || "";
$title = $opts{"t"} || "";
$term = $opts{"e"} || 'postscript enhanced color "Helvetica" 16';
$range = $opts{"r"} && '['.$opts{"r"}.']' || '';
$out = $opts{"o"} || "plot.ps";
$data_style = $opts{"s"} || "points";
$grid = $opts{"g"} && "set grid" || "unset grid";
$commands = $opts{"c"} || "";
$commands2 = "";
$plot_commands = $opts{"p"} || "";
$display = $opts{"d"};
$mode = $opts{"m"} || "none";
$threedplot = $opts{"3"} || 0;
@file_names = @ARGV or &usage();
# $ = $opts{""} || "";
#$labelfile = $opts{"l"} || "";
#$labelxcount = $opts{"m"} || 1;
#$x2tics="";
#if ($labelfile) {
# open(LF, "<$labelfile") or die("$0: Can't open '$labelfile' for reading.");
# @lf=<LF>;$lf = shift @lf; chomp $lf; $x2tics = "set x2tics 1 font \"Courier, 10\" \nset x2tics (";
# foreach $r (split //, $lf)
# {
# $x2tics .= "\"$r\" $labelxcount, ";
# $labelxcount++;
# }
# $x2tics=~s/, $/)/;
#}
if ($mode=~/square/) {
$commands="set size square\nf(x)=x\n".$commands;
$plot_commands=", f(x)".$plot_commands;
}
$commands2="pause 1000\n" if $term=~/x11/;
$files = '"'.shift @file_names;
while ($f = shift @file_names)
{$files .= '","'.$f;}
$files .= '"';
if ($data_style=~/pm3/) {
$commands="set pm3d\n".$commands;
$threedplot=1;
}
#if ($plot_commands) {$plot_commands=", $plot_commands"; }
if ($threedplot) {
$plot="splot";
} else {
$plot="plot";
}
$command = "set xlabel '$xlabel'
set ylabel '$ylabel'
set title '$title'
set style data $data_style
set out '$out'
set term $term
set timestamp 'Generated on %a %b %d %H:%M:%S %Y by $ENV{USER}'
$grid
$commands
$plot $range $files$plot_commands
$commands2
quit
";
#$x2tics
print $command if $verbose;
$gnuplot_bin = `which gnuplot 2>/dev/null || echo "/usr/bin/gnuplot"`;
#$gnuplot_bin = `echo "/usr/bin/gnuplot"`;
chomp $gnuplot_bin;
die("$0: gnuplot not available in the path.") unless (-e $gnuplot_bin);
`$gnuplot_bin <<END
$command
END`;
die("$0: gnuplot exited with an error: $?") if $?;
if ($display) {
$ps_viewer = `which gv 2>/dev/null || which kghostview 2>/dev/null || which evince 2>/dev/null || which open 2>/dev/null`;
chomp $ps_viewer;
die("$0: PS viewer not found on the computer.\n") unless $ps_viewer;
`$ps_viewer "$out"`;
}
unless ($opts{"e"})
{
open(LOG, ">>$out") or exit(0); # Don't write error, if we can't write -it's not important
print LOG "%\n%\n";
foreach (split /\n/, $command)
{
print LOG "%$_\n";
}
print LOG "%\n";
close(LOG);
}
sub usage()
{
print("Usage: $0 [options] <files>
The program will plot the files using gnuplot.
-x xlabel \t\t\t\t\t(default: '')
-y ylabel \t\t\t\t\t(default: '')
-t title \t\t\t\t\t(default: '')
-e terminal type \t\t\t\t(default: postscript color)
-o output file \t\t\t\t(default: plot.ps)
-s data style \t\t\t\t(default: dots)
-c extra commands \t\t\t\t(default: None)
-p extra commands to plot \t\t\t(default: None)
-r range (in form min:max) \t\t\t(default: Auto)
-3 the plot will be 3D (implied by style=pm3d)\t(default: No)
-v enable verbose output
-h print this helpful help message
");
exit (0);
}
#Local Variables:
#mode: perl
#mode: font-lock
#End: