Debian Codegraph @

xy-plot

raw
1 #!/bin/bash
2
3 # Public domain notice for all NCBI EDirect scripts is located at:
4 # https://www.ncbi.nlm.nih.gov/books/NBK179288/#chapter6.Public_Domain_Notice
5
6 # For Mac, please obtain command-line-enabled Plot2x from http://apps.micw.org/apps/plot2/downloads.php
7 # For Unix or PC/Cygwin, please obtain gnuplot from http://gnuplot.sourceforge.net/download.html
8
9 plot2x=
10 p2x_path=/Applications/Plot2x.app/Contents/MacOS/Plot2x
11 for pfx in "$HOME" ''
12 do
13 if [ -x "$pfx$p2x_path" ]
14 then
15 plot2x=$pfx$p2x_path
16 break
17 fi
18 done
19
20 # users may manually copy Plot2x.app into edirect folder for convenience
21 if [ -z "$plot2x" ] && [ -x "${HOME}/edirect/Plot2x.app/Contents/MacOS/Plot2x" ]
22 then
23 plot2x="${HOME}/edirect/Plot2x.app/Contents/MacOS/Plot2x"
24 fi
25
26 if [ -n "$plot2x" ]
27 then
28 cat > "$HOME/Desktop/edirect.dat"
29 outfile="$HOME/Desktop/edirect.png"
30 if [ -n "$*" ]
31 then
32 outfile="$*"
33 fi
34 cat > "$HOME/Desktop/edirect.macro" <<EOF
35 import $HOME/Desktop/edirect.dat 0
36 savepng $outfile
37 EOF
38 eval "$plot2x -m $HOME/Desktop/edirect.macro -q yes -h yes" 2>/dev/null
39 rm "$HOME/Desktop/edirect.dat"
40 rm "$HOME/Desktop/edirect.macro"
41 elif hash gnuplot 2>/dev/null
42 then
43 cat > "edirect.dat"
44 outfile="edirect.png"
45 if [ -n "$*" ]
46 then
47 outfile="$*"
48 fi
49 gnuplot -e "set terminal png; set output '$outfile'; unset key; plot 'edirect.dat' with lines"
50 rm "edirect.dat"
51 else
52 echo "To generate .png output please install either gnuplot or Plot2x" >&2
53 fi
54 if [ -f "$outfile" ]
55 then
56 case "`uname -s`" in
57 Darwin ) open "$outfile" ;;
58 CYGWIN_NT* ) cygstart "$outfile" ;;
59 * ) xdg-open "$outfile" 2>/dev/null ;;
60 esac
61 fi