Vega-lite中的散点图矩阵

时间:2019-06-12 18:33:31

标签: vega-lite

我正在尝试制作一个类似于本文中的图4的SPLOM(https://thericejournal.springeropen.com/articles/10.1186/1939-8433-7-1) 我在1987年用SYSTAT编码;忘记三角形,对角直方图和置信椭圆。我很高兴能拥有一个完整的正方形版本,在变量的边距处没有轴。附件是我到目前为止尝试过的代码的链接。 问题是,我听不到“ spacing”:2(请参见Vega Editor窗口中的第四行代码),这样我才能使这些帧卡在一起而不浪费空间。另外,我找不到用变量名称标记边距的方法。有什么想法吗?

我已经尝试过方面,并重复执行此操作。

https://github.com/vega/vega-lite/files/3282665/splom.txt

1 个答案:

答案 0 :(得分:1)

间距不是repeat的属性,而是config.repeat的属性。

关于共享轴标签:Vega-Lite尚不支持,并且跟踪错误在这里:https://github.com/vega/vega-lite/issues/2415

关于条件重复(即支持沿对角线的边际直方图),还有一个未解决的问题:https://github.com/vega/vega-lite/issues/3294

正确设置间距(vega editor link)的示例:

enter image description here

{
  "$schema": "https://vega.github.io/schema/vega-lite/v3.json",
  "repeat": {
    "column": [
      "Murder",
      "Rape",
      "Robbery",
      "Assault",
      "Burglary",
      "Larceny",
      "Autotheft"
    ],
    "row": [
      "Murder",
      "Rape",
      "Robbery",
      "Assault",
      "Burglary",
      "Larceny",
      "Autotheft"
    ]
  },
  "spec": {
    "encoding": {
      "x": {
        "field": {
          "repeat": "column"
        },
        "type": "quantitative",
        "axis": null
      },
      "y": {
        "field": {
          "repeat": "row"
        },
        "type": "quantitative",
        "axis": null
      }
    },
    "mark": {
      "size": 3.5,
      "type": "point"
    },
    "width": 50,
    "height": 50
  },
  "config": {
    "repeat": {
      "spacing": 2
    }
  },
  "data": {
    "values": [
      {
        "Rape": 7.0,
        "Robbery": 12.6,
        "Assault": 62.0,
        "Burglary": 562.0,
        "Autotheft": 146.0,
        "Murder": 1.5,
        "Larceny": 1055.0
      },
      {
        "Rape": 6.0,
        "Robbery": 12.1,
        "Assault": 36.0,
        "Burglary": 566.0,
        "Autotheft": 172.0,
        "Murder": 2.0,
        "Larceny": 929.0
      },
      {
        "Rape": 10.3,
        "Robbery": 7.6,
        "Assault": 55.0,
        "Burglary": 731.0,
        "Autotheft": 124.0,
        "Murder": 1.3,
        "Larceny": 969.0
      },
      {
        "Rape": 12.0,
        "Robbery": 99.5,
        "Assault": 88.0,
        "Burglary": 1134.0,
        "Autotheft": 878.0,
        "Murder": 3.5,
        "Larceny": 1531.0
      },
      {
        "Rape": 3.6,
        "Robbery": 78.3,
        "Assault": 120.0,
        "Burglary": 1019.0,
        "Autotheft": 859.0,
        "Murder": 3.2,
        "Larceny": 2186.0
      },
      {
        "Rape": 9.1,
        "Robbery": 70.4,
        "Assault": 87.0,
        "Burglary": 1084.0,
        "Autotheft": 484.0,
        "Murder": 3.5,
        "Larceny": 1751.0
      },
      {
        "Rape": 15.5,
        "Robbery": 443.3,
        "Assault": 209.0,
        "Burglary": 1414.0,
        "Autotheft": 682.0,
        "Murder": 7.9,
        "Larceny": 2025.0
      },
      {
        "Rape": 12.9,
        "Robbery": 169.4,
        "Assault": 90.0,
        "Burglary": 1041.0,
        "Autotheft": 557.0,
        "Murder": 5.7,
        "Larceny": 1689.0
      },
      {
        "Rape": 11.3,
        "Robbery": 106.0,
        "Assault": 90.0,
        "Burglary": 594.0,
        "Autotheft": 340.0,
        "Murder": 5.3,
        "Larceny": 1001.0
      },
      {
        "Rape": 16.0,
        "Robbery": 145.9,
        "Assault": 116.0,
        "Burglary": 854.0,
        "Autotheft": 493.0,
        "Murder": 6.6,
        "Larceny": 1944.0
      },
      {
        "Rape": 17.9,
        "Robbery": 107.5,
        "Assault": 95.0,
        "Burglary": 860.0,
        "Autotheft": 429.0,
        "Murder": 4.8,
        "Larceny": 1791.0
      },
      {
        "Rape": 20.4,
        "Robbery": 251.1,
        "Assault": 187.0,
        "Burglary": 765.0,
        "Autotheft": 518.0,
        "Murder": 9.6,
        "Larceny": 2028.0
      },
      {
        "Rape": 27.1,
        "Robbery": 346.6,
        "Assault": 193.0,
        "Burglary": 1571.0,
        "Autotheft": 464.0,
        "Murder": 9.4,
        "Larceny": 2897.0
      },
      {
        "Rape": 6.7,
        "Robbery": 33.1,
        "Assault": 44.0,
        "Burglary": 539.0,
        "Autotheft": 218.0,
        "Murder": 2.0,
        "Larceny": 1860.0
      },
      {
        "Rape": 9.7,
        "Robbery": 89.1,
        "Assault": 51.0,
        "Burglary": 802.0,
        "Autotheft": 346.0,
        "Murder": 2.0,
        "Larceny": 1902.0
      },
      {
        "Rape": 6.2,
        "Robbery": 28.6,
        "Assault": 48.0,
        "Burglary": 507.0,
        "Autotheft": 175.0,
        "Murder": 1.9,
        "Larceny": 1743.0
      },
      {
        "Rape": 27.4,
        "Robbery": 200.8,
        "Assault": 167.0,
        "Burglary": 1187.0,
        "Autotheft": 538.0,
        "Murder": 10.7,
        "Larceny": 2074.0
      },
      {
        "Rape": 6.2,
        "Robbery": 6.5,
        "Assault": 21.0,
        "Burglary": 286.0,
        "Autotheft": 91.0,
        "Murder": 0.5,
        "Larceny": 1295.0
      },
      {
        "Rape": 11.1,
        "Robbery": 17.1,
        "Assault": 60.0,
        "Burglary": 471.0,
        "Autotheft": 94.0,
        "Murder": 3.8,
        "Larceny": 1396.0
      },
      {
        "Rape": 9.3,
        "Robbery": 57.3,
        "Assault": 115.0,
        "Burglary": 505.0,
        "Autotheft": 292.0,
        "Murder": 3.0,
        "Larceny": 1572.0
      },
      {
        "Rape": 14.5,
        "Robbery": 75.1,
        "Assault": 108.0,
        "Burglary": 882.0,
        "Autotheft": 257.0,
        "Murder": 4.8,
        "Larceny": 2302.0
      },
      {
        "Rape": 18.6,
        "Robbery": 105.5,
        "Assault": 196.0,
        "Burglary": 1056.0,
        "Autotheft": 559.0,
        "Murder": 7.7,
        "Larceny": 2320.0
      },
      {
        "Rape": 23.9,
        "Robbery": 338.6,
        "Assault": 253.0,
        "Burglary": 1051.0,
        "Autotheft": 548.0,
        "Murder": 9.2,
        "Larceny": 2417.0
      },
      {
        "Rape": 15.4,
        "Robbery": 92.0,
        "Assault": 143.0,
        "Burglary": 806.0,
        "Autotheft": 297.0,
        "Murder": 8.4,
        "Larceny": 1980.0
      },
      {
        "Rape": 6.7,
        "Robbery": 27.3,
        "Assault": 84.0,
        "Burglary": 389.0,
        "Autotheft": 92.0,
        "Murder": 6.2,
        "Larceny": 774.0
      },
      {
        "Rape": 12.9,
        "Robbery": 53.0,
        "Assault": 293.0,
        "Burglary": 766.0,
        "Autotheft": 169.0,
        "Murder": 11.8,
        "Larceny": 1338.0
      },
      {
        "Rape": 18.1,
        "Robbery": 60.1,
        "Assault": 193.0,
        "Burglary": 1025.0,
        "Autotheft": 256.0,
        "Murder": 14.6,
        "Larceny": 1509.0
      },
      {
        "Rape": 10.1,
        "Robbery": 95.8,
        "Assault": 177.0,
        "Burglary": 900.0,
        "Autotheft": 309.0,
        "Murder": 15.3,
        "Larceny": 1869.0
      },
      {
        "Rape": 22.2,
        "Robbery": 186.1,
        "Assault": 277.0,
        "Burglary": 1562.0,
        "Autotheft": 397.0,
        "Murder": 12.7,
        "Larceny": 2861.0
      },
      {
        "Rape": 13.7,
        "Robbery": 72.8,
        "Assault": 123.0,
        "Burglary": 704.0,
        "Autotheft": 346.0,
        "Murder": 11.1,
        "Larceny": 1212.0
      },
      {
        "Rape": 15.5,
        "Robbery": 82.0,
        "Assault": 169.0,
        "Burglary": 807.0,
        "Autotheft": 289.0,
        "Murder": 8.8,
        "Larceny": 1025.0
      },
      {
        "Rape": 18.5,
        "Robbery": 50.3,
        "Assault": 215.0,
        "Burglary": 763.0,
        "Autotheft": 223.0,
        "Murder": 11.7,
        "Larceny": 1125.0
      },
      {
        "Rape": 8.9,
        "Robbery": 19.0,
        "Assault": 140.0,
        "Burglary": 351.0,
        "Autotheft": 78.0,
        "Murder": 11.5,
        "Larceny": 694.0
      },
      {
        "Rape": 17.1,
        "Robbery": 45.6,
        "Assault": 150.0,
        "Burglary": 885.0,
        "Autotheft": 109.0,
        "Murder": 10.1,
        "Larceny": 1211.0
      },
      {
        "Rape": 23.1,
        "Robbery": 140.8,
        "Assault": 238.0,
        "Burglary": 890.0,
        "Autotheft": 385.0,
        "Murder": 11.7,
        "Larceny": 1628.0
      },
      {
        "Rape": 15.6,
        "Robbery": 54.9,
        "Assault": 127.0,
        "Burglary": 841.0,
        "Autotheft": 280.0,
        "Murder": 5.9,
        "Larceny": 1661.0
      },
      {
        "Rape": 21.0,
        "Robbery": 134.1,
        "Assault": 195.0,
        "Burglary": 1151.0,
        "Autotheft": 394.0,
        "Murder": 11.6,
        "Larceny": 2183.0
      },
      {
        "Rape": 10.5,
        "Robbery": 22.3,
        "Assault": 75.0,
        "Burglary": 594.0,
        "Autotheft": 222.0,
        "Murder": 3.2,
        "Larceny": 1956.0
      },
      {
        "Rape": 12.3,
        "Robbery": 20.5,
        "Assault": 86.0,
        "Burglary": 674.0,
        "Autotheft": 144.0,
        "Murder": 4.6,
        "Larceny": 2214.0
      },
      {
        "Rape": 12.3,
        "Robbery": 22.0,
        "Assault": 73.0,
        "Burglary": 646.0,
        "Autotheft": 165.0,
        "Murder": 5.7,
        "Larceny": 2049.0
      },
      {
        "Rape": 36.0,
        "Robbery": 129.1,
        "Assault": 185.0,
        "Burglary": 1381.0,
        "Autotheft": 588.0,
        "Murder": 6.2,
        "Larceny": 2992.0
      },
      {
        "Rape": 21.7,
        "Robbery": 66.1,
        "Assault": 196.0,
        "Burglary": 1142.0,
        "Autotheft": 392.0,
        "Murder": 9.4,
        "Larceny": 2408.0
      },
      {
        "Rape": 27.0,
        "Robbery": 120.2,
        "Assault": 214.0,
        "Burglary": 1493.0,
        "Autotheft": 501.0,
        "Murder": 9.5,
        "Larceny": 3550.0
      },
      {
        "Rape": 10.9,
        "Robbery": 53.1,
        "Assault": 70.0,
        "Burglary": 915.0,
        "Autotheft": 316.0,
        "Murder": 3.4,
        "Larceny": 2833.0
      },
      {
        "Rape": 19.6,
        "Robbery": 188.4,
        "Assault": 182.0,
        "Burglary": 1661.0,
        "Autotheft": 661.0,
        "Murder": 8.8,
        "Larceny": 3044.0
      },
      {
        "Rape": 18.0,
        "Robbery": 93.5,
        "Assault": 106.0,
        "Burglary": 1441.0,
        "Autotheft": 362.0,
        "Murder": 3.5,
        "Larceny": 2853.0
      },
      {
        "Rape": 18.0,
        "Robbery": 102.5,
        "Assault": 132.0,
        "Burglary": 1273.0,
        "Autotheft": 333.0,
        "Murder": 4.6,
        "Larceny": 2825.0
      },
      {
        "Rape": 35.1,
        "Robbery": 206.9,
        "Assault": 226.0,
        "Burglary": 1753.0,
        "Autotheft": 689.0,
        "Murder": 6.9,
        "Larceny": 3422.0
      },
      {
        "Rape": 26.1,
        "Robbery": 71.8,
        "Assault": 168.0,
        "Burglary": 790.0,
        "Autotheft": 551.0,
        "Murder": 12.2,
        "Larceny": 2183.0
      },
      {
        "Rape": 11.8,
        "Robbery": 63.3,
        "Assault": 43.0,
        "Burglary": 1456.0,
        "Autotheft": 581.0,
        "Murder": 3.6,
        "Larceny": 3106.0
      }
    ]
  }
}