Triad sou.

annotateで背景の色分けをしてみよう

SAS/Graphのannotate機能のBAR関数を使います。

proc datasets lib = work kill; run;
option linesize = 130 pagesize = 500 mprint;
dm 'log; clear; output; clear';

%let execpath = " ";
%let Path = " ";
%macro setexecpath;
  %let execpath = %sysfunc(getoption(sysin));
  %if %length(&execpath) = 0 %then
    %let execpath = %sysget(sas_execfilepath);
  data _null_;
    do i = length("&execpath") to 1 by -1;
      if substr("&execpath", i, 1) = "\" then do;
        call symput("Path", substr("&execpath", 1, i));
        stop;
      end;
    end;
  run;
%mend setexecpath;
%setexecpath;
libname Out "&Path";


data snorm;
  do z = -5 to 5 by 0.01;
    snorm = pdf("normal", z);
    if z < -1.96 then zalpha = snorm;
    else zalpha = .;
    output;
  end;
run;

goptions reset = all;
goptions ftext = 'Times New Roman' ftitle = 'Times New Roman';
goptions vsize = 6 in hsize = 6 in htitle = 2.2 htext = 2.2;

filename grafout "&Path.snorm.bmp";
goptions device = bmp gsfname = grafout gsfmode = replace;

%let lw = 1;

data anno;
  length text $50. color $10. style $30.;
  retain xsys ysys '2' color 'cxFCFCF3';
  function = 'move'; x = -5; y = 0; output;
  function = 'bar'; x = 5; y = 0.1; style = 'solid'; output;
  function = 'move'; x = -5; y = 0.2; output;
  function = 'bar'; x = 5; y = 0.3; style = 'solid'; output;
proc gplot data = snorm;
  plot (snorm zalpha) * z / vaxis = axis1 haxis = axis2
    cautovref = cxE9DECA noframe overlay annotate = anno
    href = -1.96 lhref = 2;
  symbol1 i = splines w = &lw. c = black;
  symbol2 i = needle w = 1 c = black;
  axis1 w = &lw. minor = none major = (w = &lw.)
    label = (a = 90 f = '小塚明朝 Std R' "確率密度")
    order = (0 to .4 by .1);
  axis2 w = &lw. minor = none major = (w = &lw.)
    label = (f = 'Times New Roman/it' "Z") order = (-5 to 5);
run; quit;

xsys/ysysの設定を2にして、グラフ軸の値を座標として用いる事にします。
横軸描画領域は-5から5なので、move関数の横座標xを-5にします。ここでは、0.1幅で描く事にするのと、1個目の棒なので縦座標yは0にします。
そして、bar関数を使って四角を描画します。先ほどmove関数で指定した所を始点とし、bar関数で終点の座標を指定します。左下から右上に向かって書くので、x=5とy=0.1を指定しました。
2個目も同様に始点と終点を指定しました。
styleに'solid'を指定しておくと、上で指定した領域を塗りつぶしてくれます。


グラフの種類や目的によっては使えるかもしれません(例のグラフはあまり適切ではない)。