IPP_Description: ex_hist.dsc

File ex_hist.dsc, 1.3 KB (added by pitts, 8 years ago)

Example DVO script for making a histogram

Line 
1# This is an example DVO script that shows how to make a simple histogram
2#  diagram. This macro is designed to accept 2 arguements (vector and bin
3#  size) and outputs a histogram plot.
4
5macro ex_hist
6
7 # Display how the script is used when the macro is run without arguements
8 #  (or with an incorrect number of arguements). The macro call itself always
9 #  counts as the first arguement.
10 if ($0 != 6)
11  echo "USAGE: ex_hist (vector) (vmin) (vmax) (bin size) (output file)"
12  break
13 end
14
15 # New vector is created using the argument to avoid confusion with variables
16 set invec = $1
17
18 # Generate histogram vector using given min, max, and bin size
19 hist invec outvec $2 $3 $4
20
21 # Change the hisotgram values to a log scale
22 set outvec = log(outvec)
23
24 # Create bin vector
25 create bvec $2 $3 $4
26
27 # Create plot window
28 device -n hist
29 # Size the window
30 resize 1024 1024
31 # Create plot labels with the font set to 16-point times
32 labels -fn tines 16 -x "$1" -y "log N" +x "$1 Histogram"
33 # Draw the plot box with line thinckness 2
34 box -lw 2
35 # Plot the data with the histogram style (-x 1) and colored red and
36 #  line width of 1.5
37 plot -x 1 -c red -lw 1.5 bvec ovec
38
39 # Save plot to a postscript file
40 ps -name $5
41 echo "Plot output to file: $5"
42 echo "END EX_HIST"
43
44end