SAS - sgplot - 设置每组的透明度

时间:2015-09-24 07:41:12

标签: graph sas

在下面的示例中,我想使第1组中的数据透明(transparency = option)并保留第2组中的数据。你能救我吗?

data dat;
    input group $ x y;
    datalines;
    1 0.5 2
    1 0.8 1
    1 1   2.2
    2 4.3 5
    2 0.7 2
    ;
run;

proc sgplot data=dat;
    scatter x=x y=y / markerattrs=(symbol=circlefilled size=8); 
run;

enter image description here

1 个答案:

答案 0 :(得分:0)

在SAS 9.4 TS1M1及更高版本中,可以使用属性映射。

data dat;
    input group $ x y;
    datalines;
    1 0.5 2
    1 0.8 1
    1 1   2.2
    2 4.3 5
    2 0.7 2
    ;
run;

data group_attrmap;
    ID="groups";
    value=1;
    markercolor="cxFF0000";
    markertransparency=0.5;
    output;
    value=2;
    markertransparency=0;
    output;
run;

proc sgplot data=dat dattrmap=group_Attrmap;
    scatter x=x y=y / markerattrs=(symbol=circlefilled size=8) group=group attrid=groups;
run;

在此之前,由于不支持MARKERTRANSPARENCY,最好的选择是有两个单独的图 - 一个用于组1,一个用于组2,具有单独的透明度。你可以通过将x / y分成两组列来实现,对于另一组x / y缺失(然后没有绘制点)。

在这个特定的例子中,您也可以使用注释绘制它,因为注释散点图只是在现有数据集上设置正确的变量。