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
|
include <gset.h>
# Any other type defaults to a connected line.
define PLOT_TYPES "|line|lhist|bhist|"
define LINE 1 # Connected line
define LHIST 2 # Line histogram
define BHIST 3 # Box histogram
procedure hgpline (gp, x, y, n, type)
pointer gp #I GIO pointer
real x[ARB] #I X coordinates
real y[ARB] #I Y coordinates
int n #I Number of coordinates
char type[ARB] #I Plot type
int i
real x1, x2, bottom
char line[5]
int strdic()
begin
# Draw lines.
switch (strdic (type, line, 5, PLOT_TYPES)) {
case LHIST:
x1 = (3 * x[1] - x[2]) / 2
call gamove (gp, x1, y[1])
do i = 1, n-1 {
x2 = (x[i] + x[i+1]) / 2
call gadraw (gp, x2, y[i])
call gadraw (gp, x2, y[i+1])
x1 = x2
}
x2 = (3 * x[n] - x[n-1]) / 2
call gadraw (gp, x2, y[n])
case BHIST:
call ggwind (gp, x1, x2, bottom, x1)
x1 = (3 * x[1] - x[2]) / 2
call gamove (gp, x1, bottom)
call gadraw (gp, x1, y[1])
do i = 1, n-1 {
x2 = (x[i] + x[i+1]) / 2
call gadraw (gp, x2, y[i])
call gadraw (gp, x2, bottom)
call gadraw (gp, x2, y[i+1])
x1 = x2
}
x2 = (3 * x[n] - x[n-1]) / 2
call gadraw (gp, x2, y[n])
call gadraw (gp, x2, bottom)
default:
call gpline (gp, x, y, n)
}
end
|