1

現在、フォレスト プロット (SAS 大学版) の sgplot コードを作成しています。必要に応じて正しいグラフを取得できましたが、特定の観測の色を変更することはできません。これは私のコードです

data my_data;
    input study $ year rr lcl ucl;
    datalines;
    mickey 2015 1.5 0.7 2.3
    minny 2010 1.2 1.0 1.4
    donald 2013 0.8 0.2 1.4
    daisy 2014 1.3 1.0 1.6
    goofy 2017 1.9 0.9 2.9
    pluto 2010 1.4 0.7 2.1
    ;
run;

proc sgplot data=my_data
            noautolegend nocycleattrs; 

    scatter y=study x=rr/ markerattrs=(symbol=squarefilled size=12 color=black);
    highlow high=ucl low=lcl y=study / type=line lineattrs=(color=black);

    yaxistable study year / labelattrs=(family=arial size=12pt weight=bold) position=left location=inside valueattrs=(family=arial size=10pt);
    yaxistable rr lcl ucl / labelattrs=(family=arial size=12pt weight=bold) position=right location=inside valueattrs=(family=arial size=10pt);

    xaxis offsetmin=0.1 offsetmax=1 min=0.5 max=3.0 display=(nolabel);
    yaxis offsetmin=0.1 offsetmax=0.1 display=none reverse;

    refline 1 / axis=x;

    styleattrs axisextent=data;  
 run;

私が達成しようとしているのは、観測番号 3 (donald、2013、0.8 0.2 1.4) を赤色 (マーカー属性だけでなく、プロット時のテキスト) に変更することです。

さまざまな sgplot 属性を確認しようとしましたが、プロット時に観測番号 3 のこの特定の色を変更できません (赤、他の観測は黒のままです)。テンプレートも見ましたが、これは役に立ちません。どうすればこれを達成できますか?

4

1 に答える 1

1

決定の背後に何らかのプログラミング ロジックがあると仮定すると、1 つのアプローチは、ダミーのグループ変数を作成することです。ここで、ロジックはrr < 1.0.

問題の yaxistable へのaddcolorgroupとを削除します。attrid以下で行うように属性マップを使用するか (最も正しい)、デフォルトのグラフ色の編集を含む他のいくつかのオプションを使用して、グループに割り当てる色を (大部分を黒に戻す) かなり簡単に変更できます。

data my_data;
    length groupvar $20;
    input study $ year rr lcl ucl;
    if rr < 1.0 then groupvar='redgroup';
    else groupvar='blackgroup';
    datalines;
    mickey 2015 1.5 0.7 2.3
    minny 2010 1.2 1.0 1.4
    donald 2013 0.8 0.2 1.4
    daisy 2014 1.3 1.0 1.6
    goofy 2017 1.9 0.9 2.9
    pluto 2010 1.4 0.7 2.1
    ;
run;


data attrmap;
length value $20;
input value $ textcolor $;
retain id 'colorgroup';
datalines;
redgroup red
blackgroup black
;;;;
run;

proc sgplot data=my_data
            noautolegend nocycleattrs dattrmap=attrmap; 

    scatter y=study x=rr/ markerattrs=(symbol=squarefilled size=12 color=black) group=groupvar attrid=colorgroup;
    highlow high=ucl low=lcl y=study / type=line lineattrs=(color=black);

    yaxistable study year / labelattrs=(family=arial size=12pt weight=bold) position=left location=inside valueattrs=(family=arial size=10pt)  
                            attrid=colorgroup colorgroup=groupvar;
    yaxistable rr lcl ucl / labelattrs=(family=arial size=12pt weight=bold) position=right location=inside valueattrs=(family=arial size=10pt) ;

    xaxis offsetmin=0.1 offsetmax=1 min=0.5 max=3.0 display=(nolabel);
    yaxis offsetmin=0.1 offsetmax=0.1 display=none reverse;

    refline 1 / axis=x;

    styleattrs axisextent=data;  
 run;
于 2017-06-05T16:30:53.630 に答える