在箱形图中作为标签的值

Values as labels in Box plots

我有以下数据样本

Y     X1      X2      X3    X4     ...
123  121     214     241   241
431  143     141     241   124
214  124     214     142   241
531  432     134     412   124
243  124     134     134   123

我有兴趣使用箱形图绘制上面的数据。具体来说,我想在 x 轴 X1、X2、... 和 y 轴上将每列中的值信息作为箱线图。 然而,由于我想在视觉上识别相应的 Y' 值(例如,对于最大 X1 将是 531),我考虑使用一些标签。 为了创建箱形图,我使用

ods graphics off;
proc boxplot data=test;
   plot Y*X;
run;

其中 X 是

X    Y
X1  121
X1  143
X1  124
X1  432
... ...
X2  214
X2  141
X2  214
...

但是,如上所示,我丢失了 Y 的值(即 123、431 等)。 有没有办法将这些信息也保存在(框)图中?任何其他想法也将被考虑和赞赏。

转置您的数据,您将能够使用 Proc SGPLOT 语句 HBOX

示例:

data have;
input 
Y     X1      X2      X3    X4 ;
datalines;
123  121     214     241   241
431  143     141     241   124
214  124     214     142   241
531  432     134     412   124
243  124     134     134   123
;

proc transpose data=have out=tall (rename=col1=x);
  by y notsorted;
  var x1-x4;
run;

ods html file='hbox-plot.html';

proc sgplot data=tall;
   hbox x / category=y;
   yaxis type=linear;
run;

ods html close;

会产生