[37] | 1 | function o = graph_idraw(ifile, means, stds_low, stds_hi, minval, maxval) |
---|
| 2 | % This writes to an idraw file a set of lines that graph a set of function values |
---|
| 3 | % along with error bars. |
---|
| 4 | % Values are assumed to lie in between MINVAL and MAXVAL. |
---|
| 5 | % If STDS has a zero value, no error bar is drawn. (not implemented) |
---|
| 6 | % stds_low is mean-std, stds_hi is mean+std. We don't just pass stds |
---|
| 7 | % in case a log scale is used. |
---|
| 8 | |
---|
| 9 | % For this to work, ifile must already contain a template idraw file, generated |
---|
| 10 | % with a line, that is then removed. The end of the file must be removed, and must be |
---|
| 11 | % added later. It looks like: |
---|
| 12 | |
---|
| 13 | %End %I eop |
---|
| 14 | |
---|
| 15 | %showpage |
---|
| 16 | |
---|
| 17 | %%%Trailer |
---|
| 18 | |
---|
| 19 | %end |
---|
| 20 | |
---|
| 21 | o = 1; |
---|
| 22 | irec_lx = 50; |
---|
| 23 | irec_ly = 50; |
---|
| 24 | irec_ux = 500; |
---|
| 25 | irec_uy = 500; |
---|
| 26 | % We write to an image rectangle with l giving lower corner, u upper. |
---|
| 27 | stdline = 5;
|
---|
| 28 | dotrad = 6; |
---|
| 29 | |
---|
| 30 | numvals = size(means,2); |
---|
| 31 | x_len = irec_ux - irec_lx; |
---|
| 32 | xspace = x_len/(numvals + 1); |
---|
| 33 | xvals = round(irec_lx + xspace*(1:numvals)); |
---|
| 34 | |
---|
| 35 | y_len = irec_uy - irec_ly; |
---|
| 36 | yvals = round(irec_ly + y_len*(means - minval)./(maxval-minval));
|
---|
| 37 |
|
---|
| 38 | if ~isempty(stds_low) |
---|
| 39 | ystdmin = round(irec_ly + y_len*(stds_low - minval)./(maxval-minval)); |
---|
| 40 | ystdmax = round(irec_ly + y_len*(stds_hi - minval)./(maxval-minval)); |
---|
| 41 | end
|
---|
| 42 | |
---|
| 43 | fid = fopen(ifile, 'a'); |
---|
| 44 | for i = 1:numvals |
---|
| 45 | x = xvals(i);
|
---|
| 46 | if ~isempty(stds_low) |
---|
| 47 | ymin = ystdmin(i); |
---|
| 48 | ymax = ystdmax(i); |
---|
| 49 | line_idraw(fid, x, ymin, x, ymax); |
---|
| 50 | line_idraw(fid, x-stdline, ymin, x+stdline, ymin); |
---|
| 51 | line_idraw(fid, x-stdline, ymax, x+stdline, ymax);
|
---|
| 52 | end
|
---|
| 53 | dot_idraw(fid, x, yvals(i), dotrad); |
---|
| 54 | end |
---|
| 55 | for i = 1:(numvals - 1) |
---|
| 56 | x = xvals(i); |
---|
| 57 | nextx = xvals(i+1); |
---|
| 58 | y = yvals(i); |
---|
| 59 | nexty = yvals(i+1); |
---|
| 60 | line_idraw(fid, x, y, nextx, nexty); |
---|
| 61 | end |
---|
| 62 | fclose(fid); |
---|