在箱形图中作为标签的值 [英] Values as labels in Box plots

查看:84
本文介绍了在箱形图中作为标签的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下数据样本

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),我考虑过使用一些标签.为了创建箱形图,我正在使用

I would be interested in plotting using box plots the data above. Specifically, I would like to have on the x-axis X1, X2, ... and on the y-axis the information of values within each column as a box plot. However, since I would like to identify visually, the corresponding Y'value (e.g., for max X1 would be 531), I thought about using some labels. For creating the box plot, I am using

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等).有什么办法可以将这些信息也保存在(箱形)图中?任何其他想法也将被考虑和赞赏.

As shown above, however, I am loosing the values of Y (i.e. 123, 431, ...). Is there any way to keep also this information in a (box) plot? Any other ideas would be also kept into consideration and appreciated.

推荐答案

转置数据,您将可以使用 Proc SGPLOT 语句 HBOX .

Transpose your data and you will be able to use Proc SGPLOT statement 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;

会产生

这篇关于在箱形图中作为标签的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆