多维数据绘图

时间:2017-05-14 08:57:53

标签: javascript plot charts sas

我有一个数据集,其中每个观察(由ID标识)有多个(4+)度量。每个度量都有一个全局截止值:每个度量一个,它适用于所有观察。我想在图表上可视化这些数据点,包括截止值,以便可以快速识别超过截止值的数据点。

在二维图形上,这可以通过散点图和表示截止值的直线轻松完成,但在多维情况下看起来并不那么容易。

我已经研究过Radar和Polar图表。它们的问题在于每次观察(ID)被多次表示,因此很难看出哪些点超过了至少一个度量的截止值。

    ID  Measure         Value
    1   Avg Size        100
    1   Max Throughput  1000
    1   Inc Diff        1.56
    1   Max Value       10000000
    2   Avg Size        150
    2   Max Throughput  1500
    2   Inc Diff        2.4
    2   Max Value       10000000
    3   Avg Size        250
    3   Max Throughput  900
    3   Inc Diff        0.5
    3   Max Value       15000000

技术解决方案并不特别重要。我试图在SAS中完成这个任务;有许多有趣的JavaScript图表库,它们也可以使用。

我正在寻找多维(4维)场景中的可视化示例。

1 个答案:

答案 0 :(得分:1)

你并不孤单奋斗!

这是我正在使用的模拟数据:

/*Simulate reproducible random data. Six dimensions.*/
data have;
    do id=1 to 20;
        measure_1 = ceil(ranuni(_N_    )*10   );
        measure_2 = ceil(ranuni(_N_+20 )*100  );
        measure_3 = ceil(ranuni(_N_+40 )*1000 );
        measure_4 = ceil(ranuni(_N_+60 )*10000);
        measure_5 = ceil(ranuni(_N_+80 )*1000 );
        measure_6 = ceil(ranuni(_N_+100)*100  );
        output;
    end;
run;

我没有代表截止点,但您可以使用注释表示一些维度截止。下面是一种至少表示5个维度的方法(ActiveX交互图,使用IE查看):

/*Visually represent 5 of the 6 dimensions, however visualizing the thresholds is hard.*/
data have_prepare;
    set have;
    length measure_3_color $8;
    measure_2_size  = measure_2/50;
    measure_3_color = cats("CX",put((measure_3/1000)*256,hex2.),'FF',put(256-(measure_3/1000)*256,hex2.));
run;

/*Output Java ActiveX graph for user manipulation.*/
ods html file="C:\test_activex.html";
goptions reset=all device=activex 
         border xpixels=600 ypixels=400 
     cback=white;  
title1 "5 dimension representation";
title2 "Measures 4 to 6 are spatial, Measure 2 is shape size, Measure is color";
title3 "Right-click to use the 'Graph Toolbar'";
proc g3d data=have_prepare;
  scatter measure_4*measure_5=measure_6 / noneedle
     color=measure_3_color
     size=measure_2_size
     shape="BALLOON";
run;
quit;
ods html close; 

enter image description here

如果您愿意采用不那么花哨的方式来查看数据,那么只需使用proc printproc format more detail hereenter image description here),您就可以根据需要投放多个维度:

/*Using PROC PRINT with traffic lighting could work?*/
/*Create formats to color cell backgrounds corresponding to values outside predetermined cut-offs*/
proc format;
    value m1_thresh_bg_fmt  low-8   = 'white'
                            9-high  = 'red';

    value m2_thresh_bg_fmt  low-75  = 'white'
                            76-high = 'red';

    value m3_thresh_bg_fmt  low-100  = 'CX0000FF' /*blue*/
                            101-900  = 'CXFFFFFF' /*white*/
                            901-high = 'CXFF0000' /*red*/;

    value m4_thresh_bg_fmt  low-2000  = 'red'
                            2001-high = 'white';

    value m5_thresh_bg_fmt  low-60  = 'red'
                            61-high = 'white';

    value m6_thresh_bg_fmt  low-90  = 'white'
                            91-high = 'red';
run;

ods html file="C:\test_print.html";
proc print data=have noobs;
    var id;
    var measure_1 / style(data)={background=m1_thresh_bg_fmt.};
    var measure_2 / style(data)={background=m2_thresh_bg_fmt.};
    var measure_3 / style(data)={background=m3_thresh_bg_fmt.};
    var measure_4 / style(data)={background=m4_thresh_bg_fmt.};
    var measure_5 / style(data)={background=m5_thresh_bg_fmt.};
    var measure_6 / style(data)={background=m6_thresh_bg_fmt.};
run;

{{3}}