49 if ( plsc->level < 1 )
51 plabort(
"plhist: Please call plinit first" );
54 if ( plsc->level < 3 && ( flags & 1 ) )
56 plabort(
"plhist: Please set up window first" );
59 if ( datmin >= datmax )
61 plabort(
"plhist: Data range invalid" );
64 if ( !( x = (
PLFLT *) malloc( (
size_t) nbin *
sizeof (
PLFLT ) ) ) )
66 plabort(
"plhist: Out of memory" );
69 if ( !( y = (
PLFLT *) malloc( (
size_t) nbin *
sizeof (
PLFLT ) ) ) )
72 plabort(
"plhist: Out of memory" );
76 dx = ( datmax - datmin ) / nbin;
77 for ( i = 0; i < nbin; i++ )
79 x[i] = datmin + i *
dx;
83 for ( i = 0; i < n; i++ )
85 bin = (
PLINT) ( ( data[i] - datmin ) /
dx );
86 if ( ( flags & 2 ) == 0 )
88 bin = bin > 0 ? bin : 0;
89 bin = bin < nbin ? bin : nbin - 1;
94 if ( bin >= 0 && bin < nbin )
101 if ( !( flags & 1 ) )
104 for ( i = 0; i < nbin; i++ )
105 ymax =
MAX( ymax, y[i] );
110 plbin( nbin, x, y, ( flags & ( 4 + 8 + 16 + 32 ) ) >> 2 );
132 if ( plsc->level < 3 )
134 plabort(
"plbin: Please set up window first" );
140 for ( i = 0; i < nbin - 1; i++ )
142 if ( x[i] >= x[i + 1] )
144 plabort(
"plbin: Elements of x array must be increasing" );
149 plP_xgvpw( &vpwxmi, &vpwxma, &vpwymi, &vpwyma );
150 if ( !( flags & 1 ) )
152 for ( i = 0; i < nbin - 1; i++ )
154 if ( !( flags & 4 ) || ( y[i] != vpwymi ) )
156 pljoin( x[i], vpwymi, x[i], y[i] );
157 pljoin( x[i], y[i], x[i + 1], y[i] );
158 pljoin( x[i + 1], y[i], x[i + 1], vpwymi );
163 if ( !( flags & 4 ) || ( y[i] != vpwymi ) )
165 int xm = (int) ( x[i] + ( x[i] - x[i - 1] ) );
166 pljoin( x[i], vpwymi, x[i], y[i] );
167 pljoin( x[i], y[i], xm, y[i] );
168 pljoin( xm, y[i], xm, vpwymi );
175 if ( !( flags & 4 ) || ( y[i] != vpwymi ) )
177 pljoin( x[i], vpwymi, x[i], y[i] );
178 pljoin( x[i], y[i], vpwxma, y[i] );
179 pljoin( vpwxma, y[i], vpwxma, vpwymi );
190 xmin =
MAX( vpwxmi, 0.5 * ( 3 * x[0] - x[1] ) );
197 xmax =
MAX( 0.5 * ( x[0] + x[1] ), vpwxmi );
200 pljoin( xmin, vpwymi, xmin, y[0] );
201 pljoin( xmin, y[0], xmax, y[0] );
202 pljoin( xmax, y[0], xmax, vpwymi );
204 for ( i = 1; i < nbin - 1; i++ )
207 xmax =
MIN( 0.5 * ( x[i] + x[i + 1] ), vpwxma );
208 if ( !( flags & 4 ) || ( y[i] != vpwymi ) )
210 pljoin( xmin, vpwymi, xmin, y[i] );
211 pljoin( xmin, y[i], xmax, y[i] );
212 pljoin( xmax, y[i], xmax, vpwymi );
219 xmax =
MIN( vpwxma, 0.5 * ( 3 * x[i] - x[i - 1] ) );
227 if ( !( flags & 4 ) || ( y[i] != vpwymi ) )
229 pljoin( xmin, vpwymi, xmin, y[i] );
230 pljoin( xmin, y[i], xmax, y[i] );
231 pljoin( xmax, y[i], xmax, vpwymi );
void PLFLT PLINT PLINT PLFLT x
void c_plbin(PLINT nbin, const PLFLT *x, const PLFLT *y, PLINT flags)
void PLFLT PLINT PLINT PLFLT PLFLT y
void c_plhist(PLINT n, const PLFLT *data, PLFLT datmin, PLFLT datmax, PLINT nbin, PLINT flags)
void plabort(const char *errormsg)
void plP_xgvpw(PLFLT *p_xmin, PLFLT *p_xmax, PLFLT *p_ymin, PLFLT *p_ymax)
dx
if { $zoomopts($this,1) == 0 } then {