Method: Pgplot.pghist

Defined in:
ext/rb_pgplot.c

.pghist(*args) ⇒ Object

PGHIST – histogram of unbinned data

pghist, data, nbin [,range, flag]
data   : the data values. NBIN may not exceed 200.
nbin   : the number of bins to use
range  : the range for the histogram.
flag   : = 0 PGENV is called automatically
  = 1 the histogram is plotted in the current window.
  = 2,3 with a filled area style.
  = 4,5 simple line.


251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'ext/rb_pgplot.c', line 251

static VALUE
  rb_pgplot_pghist( int argc, VALUE *argv, VALUE self )
{
  VALUE vdat,vnbin,vrange,vflag;
  VALUE na_dat;
  int flag=0;
  float range[2];

  rb_scan_args(argc,argv, "22", &vdat,&vnbin,&vrange,&vflag);
  na_dat = rb_pgplot_fltary( vdat );

  /* Data Range */
  if (vrange!=Qnil) {
    range[0] = NUM2DBL(rb_funcall(vrange, id_beg, 0));
    range[1] = NUM2DBL(rb_funcall(vrange, id_end, 0));
  } else {
    rb_pgplot_minmax(na_dat,range);
  }
  /* PGFLAG */
  if (vflag!=Qnil) flag = NUM2INT(vflag);

  cpghist( NA_TOTAL(na_dat), NA_PTR_FLT(na_dat),
     range[0], range[1], NUM2INT(vnbin), flag );
  return Qtrue;
}