-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplt_hist.c
54 lines (38 loc) · 879 Bytes
/
plt_hist.c
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
#include "plplot/plplot.h"
#include "plplot/plstrm.h"
#include <stdlib.h>
#ifdef PL_HAVE_UNISTD_H
# include <unistd.h>
#else
# ifdef PL_HAVE_POLL
# include <poll.h>
# endif
#endif
int plt_hist(float *x, int n, float x_min, float x_max, int nbin, char *xlab, char *ylab, char *ttl){
int i, pnbin;
static PLFLT *xd, px_min, px_max;
xd = malloc(n*sizeof(PLFLT));
for(i=0; i<n; i++)
*(xd+i) = *(x+i);
pnbin = nbin;
px_min = x_min;
px_max = x_max;
// Initialize plplot
plinit();
plschr(0, .5);
plenv(0.0, px_max, 0.0, 10*n/(nbin), 0, -2);
plwind( 0.0, px_max, 0.0, 10*n/nbin);
plbox("bcinst", 5, 0, "bcinst", 0, 0);
plcol0(2);
plhist(n, xd, x_min, x_max, nbin, 3);
//put labels on axes
plcol0(3);
pllab (xlab, ylab, ttl);
/*
plcol0(3);
plmtex("b", 3.2, .5, .5, xlab);
plmtex("l", 5, .5, .5, ylab);
plmtex("t", 2, .5, .5, ttl);
*/
plend();
}