使用 J 创建散点图矩阵

Creating a scatterplot matrix with J

我正在命令行上做一些数据科学,发现 J 是基本分析(统计)任务的便捷工具。在几年前对这门语言有了一些初步的感觉之后,我不得不重新开始作为一个完全的菜鸟。如果我现在遇到的问题能得到一些帮助,那就太好了。

我有一组测量属性,想直观地显示相关性。该视图通常称为散点图矩阵,一个很好的例子是 here。我认为可以在 J 中使用其出色的绘图库创建类似的图形。

到目前为止我做了什么:

NB. For sake of brevity, my test data is simulated here comprising 4 attributes with 7 measurements:
   ]A=:i. 7 4
 0  1  2  3
 4  5  6  7
 8  9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
24 25 26 27

NB. With the aid of a sparse matrix I created the index matrix of the multiplot matrix/layout
   ]Idx=: 4 $. $. 4 4
0 0
0 1
0 2
0 3
1 0
1 1
1 2
1 3
2 0
2 1
2 2
2 3
3 0
3 1
3 2
3 3

NB. Creating a single plot work fine with this sentence, here showing attribute 1 vs 3.
'TYPE marker' plot 1 1 <;.1 |: 3 1 {"1 A

NB. And here is my failed approach for creating a (multiplot) scatterplot matrix
   pd 'multi 4 4'
   3 : 0''
for_ijk. Idx do.
pd 1 1 <;.1 |: ijk {"1 A
end.
)
   pd 'show'

首先,通过循环执行此操作在 J 中感觉不对。是否有更好的方法为每个绘图元素注入索引?

其次,循环没有正确地将数据提供给绘图 (pd),但我找不到将所有结果附加到大矩阵并仅将其提供给 pd 的方法。

非常欢迎任何想法!非常感谢。

你的方法很好,除了 pd-multi 需要,据我所知,所有数据一次作为 2 元素列表的盒装列表:

(options1;data1) ; (options2;data2) ; ... 

一种可行的方法是:

options =: 'type marker'
pd'reset'
pd'multi 4 4'
pd (options; <)"1 (A&({"1~)) &.> Idx
pd 'show'

假设 options 对所有地块都是通用的。