/usr/bin/gbplot is in gbutils 5.7.0-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | #!/bin/sh
# gbplot ver. 1.1 Copyright (C) 2009-2010 Giulio Bottazzi
#read command line options; the position of the last option is saved
#in OPTIND
while getopts "T:o:t:p:ihl:C:v-:" opt
do
case $opt in
-)
case "${OPTARG}" in
help) help=yes;;
version) version=yes;;
esac;;
T) terminal=$OPTARG;;
o) outfile=$OPTARG;;
t) title=$OPTARG;;
p) prestring=$OPTARG;;
i) interactive=yes;;
h) help=yes;;
l) setlog=$OPTARG;;
C) precommand="${precommand}; $OPTARG";;
v) verbose=yes;;
\?) help=yes;;
esac
done
if [ "$version" = "yes" ]; then
cat - <<EOF
gbplot ver. 5.6
Copyright (C) 2009-2014 Giulio Bottazzi
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
(version 2) as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Written by Giulio Bottazzi
Report bugs to <gbutils@googlegroups.com>
Package home page <http://cafim.sssup.it/~giulio/software/gbutils/index.html>
EOF
exit
fi
if [ "$help" = "yes" ]; then
cat - <<EOF
Usage: gbplot [options] [command] [specstring] < datafile
This command produce simple plots from the command line using the
'gnuplot' program. 'comand' is one of the gnuplot commands: 'plot' or
'splot' while 'specstring' is a list of gnuplot specifications. In
order to escape shell interpretation place 'specstring' between double
quotes. It is possible to specify the type of terminal and output file
name as command line options. It is also possible to start an
interactive session, useful to adjust plot parameters by hand. The
program can be used in a shell pipe, as in
cat datafile | gbplot [options] [command] [specstring]
Options:
-h print this help
-i start interactive session after the plot
-T set a different terminal
-o set an ouptut file
-t assign a title to the plot
-p prepend expression to plot command
-l set log; possible values x,y and xy
-C command to be run before the plot
-v verbose output: print commands to standard error
--help same as '-h'
--version print the program version
Examples:
Two plots: one using line and one using points.
echo "1\n2\n3" | gbplot plot "u 0:1 w l title 'line', '' u 0:1 w p title 'point'"
Save the plot in PDF format in a file named 'test.pdf'
echo "1\n2\n3" | gbplot -T pdf -o test.pdf plot "u 0:1 w l title 'line'"
Set log on the y axis
echo "1\n2\n3" | gbplot -l y plot "u 0:1 w l title 'line', '' u 0:1 w p title 'point'"
Set log on the x axis and a grid
echo "1\n2\n3" | gbplot -l x -C "set grid" plot "u 0:1 w l title 'line', '' u 0:1 w p title 'point'"
Set a grid and the position of the legend
echo "1\n2\n3" | gbplot -C "set grid" -C "set key bottom right" plot "u 0:1 w l title 'line', '' u 0:1 w p title 'point'"
Compute the value of the gamma function on a set of points; gawk is used to filer the relevant numbers
echo "1\n2\n3" | gbplot -C "set table" plot 'u (gamma($1))' | gawk '/ i/{print $2}'
EOF
exit
fi
#store provided data
cat - > .gb.data
#check the syntax and define plotting parameters
#plotcmd=${@:$OPTIND:1} <- bashism
shift `expr $OPTIND - 1`
plotcmd=$1
if [ "$plotcmd" != "plot" ] && [ "$plotcmd" != "splot" ]; then
echo "provide a plot or splot command"
exit
fi
#firstpar=${@:$(( OPTIND+1 )):1} <- bashism
#plotpar=${@:$(( OPTIND+2 ))} <- bashism
shift
firstpar=$1
shift
plotpar=$@
#identify range specification
if echo "$firstpar" | grep '\[*\]' > /dev/null; then
plotcmd="$plotcmd $firstpar"
else
plotpar="$firstpar $plotpar"
fi
#set the default terminal
if echo "set term" | gnuplot 2>&1 | grep wx > /dev/null; then
DEFTERM=wxt
else
DEFTERM=x11
fi
#-----------------------------------------------
if [ "$interactive" = "yes" ]; then #interactive session
#create temporary files
CMDFILE=`tempfile`
ENDFILE=`tempfile`
# --- initial gnuplot commands
#set the default terminal
echo "set term $DEFTERM noraise" >> $CMDFILE
#next line useful for screen to start in present directory
echo "cd \"$PWD\"" >> $CMDFILE
#no need of irrelevant titles
echo "set key noautotitle" >> $CMDFILE
#prepend expression
if [ "$prestring" != "" ]; then
echo "$prestring" >> $CMDFILE
fi
#add title
if [ "$title" != "" ]; then
echo "set title \"$title\"" >> $CMDFILE
fi
#set log scale
if [ "$setlog" != "" ]; then
echo "set log $setlog" >> $CMDFILE
fi
#add pre-plot command
if [ "$precommand" != "" ]; then
echo "$precommand" >> $CMDFILE
fi
echo "$plotcmd \".gb.data\" $plotpar" >> $CMDFILE
echo "show plot" >> $CMDFILE
# ----------------------------
# --- final gnuplot commands
#prepare for final output if 'terminal' or 'outfile' is specified
if [ "$terminal" != "" ]; then
echo "set term $terminal" >> $ENDFILE
fi
if [ "$outfile" != "" ]; then
echo "set out \"$outfile\"" >> $ENDFILE
echo "replot" >> $ENDFILE
echo "set out" >> $ENDFILE
fi
#remove temporary files
echo "!rm .gb.data" >> $ENDFILE
echo "!rm $CMDFILE $ENDFILE" >> $ENDFILE
# ----------------------------
if [ "$verbose" = "yes" ]; then
cat $CMDFILE > /dev/stderr
echo "-- session -- " > /dev/stderr
cat $ENDFILE > /dev/stderr
fi
if [ "$TERM" = "screen" ]; then
#start gnuplot in a new screen window
screen -X screen gnuplot $CMDFILE - $ENDFILE
else
#start gnuplot in a new X terminal
aterm -e gnuplot $CMDFILE - $ENDFILE
fi
else #non-interactive session
#create temporary files
CMDFILE=`tempfile`
#next line useful for screen to start in present directory
echo "cd \"$PWD\"" >> $CMDFILE
#no need of irrelevant titles
echo "set key noautotitle" >> $CMDFILE
if [ "$terminal" != "" ]; then
echo "set term $terminal" >> $CMDFILE
else
echo "set term $DEFTERM noraise" >> $CMDFILE
fi
if [ "$outfile" != "" ]; then
echo "set out \"$outfile\"" >> $CMDFILE
fi
#prepend expression
if [ "$prestring" != "" ]; then
echo "$prestring" >> $CMDFILE
echo "$prestring"
fi
#add title
if [ "$title" != "" ]; then
echo "set title \"$title\"" >> $CMDFILE
fi
#set log scale
if [ "$setlog" != "" ]; then
echo "set log $setlog" >> $CMDFILE
fi
#add pre-plot command
if [ "$precommand" != "" ]; then
echo "$precommand" >> $CMDFILE
fi
echo "$plotcmd \".gb.data\" $plotpar" >> $CMDFILE
if [ "$verbose" = "yes" ]; then
cat $CMDFILE > /dev/stderr
fi
gnuplot -persist ${CMDFILE}
rm .gb.data
rm "$CMDFILE"
fi
|