【问题标题】:SGPLOT : Scatter plot is overlaying data points on graphSGPLOT:散点图覆盖图形上的数据点
【发布时间】:2016-04-05 17:26:04
【问题描述】:

我正在尝试创建一个按条件分组的散点图。在下面的示例中,我有一些数据点(连续变量)在分类变量 MAKE 之间是常见的。所以数据点被覆盖了,这让我无法确定图表是代表两个变量的存在还是一个变量的存在。

如何通过在 SGPLOT 过程中使用两个不同的符号来避免它,就像我们在 GPLOT 中使用的方式一样。我使用的 SGPLOT 示例代码:

proc sgplot data=sashelp.cars(where=(make in ('Dodge', 'Chrysler')));
scatter Y=mpg_city X=mpg_highway / group=make markerattrs=(symbol=plus);
run;

我知道下面的代码可以工作,但我想使用 SGPLOT 而不是 GPLOT:

ods listing close;
SYMBOL1 VALUE=dot color=bib; 
SYMBOL2 VALUE=square color=brown;
proc gplot data=sashelp.cars(where=(make in ('Dodge', 'Chrysler')));
plot mpg_city * mpg_highway =make ;
run;

提前致谢。

【问题讨论】:

    标签: sas


    【解决方案1】:

    嗯,当然是使用一个符号。你说的!

    删除您的MARKERATTR=(symbol= 代码,或者使用MARKERCHAR 使其来自变量或属性映射数据集 (DATTRMAP) 以这种方式指定它,如果您希望能够指定两个标记具体来说。或者使用颜色。

    这里有几个例子:

    *Using MARKERCHAR;
    data cars;
      set sashelp.cars;
      if make = 'Dodge' then marker_char = '+';
      else if make = 'Chrysler' then marker_char = 'o';
      else delete;
    run;
    
    proc sgplot data=cars(where=(make in ('Dodge', 'Chrysler')));
    scatter Y=mpg_city X=mpg_highway / group=make markerchar=marker_char;
    run;
    
    
    *Using an attribute map (most similar to the GPLOT example);
    data attr_map;
      length value markercolor $8;
      id='MakeAttr';
      value = 'Dodge';
      markersymbol='plus';
      markercolor='green';
      output;
      value='Chrysler';
      markersymbol='circle';
      markercolor='red';
      output;
    run;
    
    
    ods html style=htmlblue;
    proc sgplot data=sashelp.cars(where=(make in ('Dodge', 'Chrysler'))) dattrmap=attr_map;
    scatter Y=mpg_city X=mpg_highway / group=make attrid=MakeAttr;
    run;
    

    【讨论】:

      猜你喜欢
      • 2019-07-02
      • 2020-06-12
      • 1970-01-01
      • 1970-01-01
      • 2021-05-03
      • 1970-01-01
      • 1970-01-01
      • 2021-10-27
      相关资源
      最近更新 更多