1
/*===========================================================================
2
Copyright (C) 1995-2009 European Southern Observatory (ESO)
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; either version 2 of
7
the License, or (at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public
15
License along with this program; if not, write to the Free
16
Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
19
Corresponding concerning ESO-MIDAS should be addressed as follows:
20
Internet e-mail: midas@eso.org
21
Postal address: European Southern Observatory
22
Data Management Division
23
Karl-Schwarzschild-Strasse 2
24
D 85748 Garching bei Muenchen
26
===========================================================================*/
29
* HEADER : ag_hist.c - Vers 3.6.000 - Oct 1991 - L. Fini, Oss. Arcetri
31
* AGL high level routine. Histogram generation
41
static void drwbin(xvaux,yvaux,xcurr,xnext,ynext,yzero,mode)
42
float xvaux[],yvaux[];
43
float xcurr,xnext,ynext,yzero;
46
xvaux[1] = xcurr+(xnext-xcurr)*0.5;
48
(void)AG_GPLL(xvaux,yvaux,2);
72
(void)AG_GPLL(xvaux,yvaux,2);
78
/*****************************************************************************/
79
/*++ AG_HIST (User callable) */
84
/* This module draws various forms of histogram plots from a couple of */
85
/* coordinate vectors. */
87
/* NOTE: a window must be defined and the mode USER must be selected before */
88
/* calling AG_HIST (see: AG_WDEF and AG_SSET). */
90
/* Here follows a typical calling sequence for histogram plotting: */
92
/* AG_VDEF (.......) Define graphic device */
93
/* AG_AXES(x0,x1,y0,y1,sel) Define and draw axes */
94
/* AG_HIST(xv,yv,np,0,0) Draw the histogram from data in vectors */
95
/* xv,yv (length=np) */
96
/* AG_CLS() Close AGL */
99
void AG_HIST(xv,yv,np,mode,join)
101
float xv[],yv[]; /* Coordinate arrays */
103
int np; /* Array length */
105
int mode; /* Histogram type selection. */
106
/* Types available are the following: */
108
/* mode=0 simple staircase. */
109
/* mode=1 staircase steps joined to x-axis. */
110
/* mode<=2 data points joined to x-axis with */
111
/* boxes (current line width and style)*/
112
/* with width starting from 0 (simple */
113
/* line) and increasing with mode */
114
/* value in steps of small character */
116
int join; /* Flag to join more than one call into a */
117
/* single histogram (used with modes: 0, 1) */
118
/* join=0 : histogram closed at both ends. */
119
/* (used when all data points are */
120
/* plotted with a single call) */
121
/* join=1 : histogram opened at the right end */
122
/* (used for the first block of an */
123
/* histogram built with many calls) */
124
/* join=2 : histogram opened at the left end */
125
/* (used for the final block of an */
126
/* histogram built with many calls) */
127
/* join=3 : histogram opened at both ends */
128
/* (used for the middle blocks of an */
129
/* histogram built with many calls) */
130
/* N.B.: when using the join feature to plot a */
131
/* long histogram built up with pieces */
132
/* DO NOT intermix calls to other AGL */
133
/* routines between calls to AG_HIST. */
136
static char *modnam = "HIST";
137
static float xvaux[4],yvaux[4];
138
static float xcurr,xnext,ynext,yzero;
142
AG_DMSG(modnam,(char *)0);
148
(void)AG_RGET("wndl",wndl);
158
delta = (xv[1]-xv[0])*0.5; /* deal with left */
159
xvaux[0] = xv[0]-delta; /* edge of histogram */
167
AG_GPLL(xvaux,yvaux,2);
171
xnext=xv[0]; /* xcurr is the last point */
172
ynext=yv[0]; /* of previous block */
173
drwbin(xvaux,yvaux,xcurr,xnext,ynext,yzero,mode);
176
for(i=0; i<np-1; i++) { /* This for the central part */
181
drwbin(xvaux,yvaux,xcurr,xnext,ynext,yzero,mode);
183
xcurr=xv[np-1]; /* needed for joining */
185
} else { /* Modes >= 2 */
188
for(i=0; i<np; i++) {
193
(void)AG_GPLL(xvaux,yvaux,2);
198
(void)AG_RGET("nchdim",fv);
199
(void)AG_SSET("normal");
201
for(i=0; i<np; i++) {
202
AG_VU2N(xv[i],yzero,xvaux,yvaux);
203
AG_VU2N(xv[i],yv[i],xvaux+1,yvaux+1);
204
xvaux[2] = xvaux[0]+hbin;
205
xvaux[3] = xvaux[0]+hbin;
210
(void)AG_GPLL(xvaux,yvaux,4);
216
if(((join&01)==0)&&(mode<2)) { /* deal with right edge of histogram */
217
xnext=xcurr+2.0*delta;
219
drwbin(xvaux,yvaux,xcurr,xnext,ynext,yzero,mode);