如何创建分解数据图表到类别?

时间:2018-08-28 15:09:58

标签: plot charts wolfram-mathematica

我正在寻找可以创建以下图形的程序或库:

想法如下:

  • W有一些初始值
  • 分为不同的状态
  • 这些分裂可能会发生几次
  • 我们要提供与每个州有关的名称和值

是否可以在Wolfram Mathematica中生成这样的图像?如果是,我应该使用哪些功能。

enter image description here

此图上显示的图形显示了Tinder应用程序的使用历史。

来源:

  

https://www.reddit.com/r/dataisbeautiful/comments/83ttdq/oc_my_28_days_on_tinder/

1 个答案:

答案 0 :(得分:0)

我决定不使用Mathematica,而是在JavaScript中创建此图。

  

https://www.amcharts.com/docs/v4/chart-types/sankey-diagram/

/**
 * ---------------------------------------
 * This demo was created using amCharts 4.
 *
 * For more information visit:
 * https://www.amcharts.com/
 *
 * Documentation is available at:
 * https://www.amcharts.com/docs/v4/
 * ---------------------------------------
 */

// Create chart instance
var chart = am4core.create("chartdiv", am4charts.SankeyDiagram);

chart.data = [
  { "from": "A", "to": "D", "value": 10 },
  { "from": "B", "to": "D", "value": 8 },
  { "from": "B", "to": "E", "value": 4 },
  { "from": "C", "to": "E", "value": 3 },
  { "from": "D", "to": "G", "value": 5 },
  { "from": "D", "to": "I", "value": 2 },
  { "from": "D", "to": "H", "value": 3 },
  { "from": "E", "to": "H", "value": 6 },
  { "from": "G", "to": "J", "value": 5 },
  { "from": "I", "to": "J", "value": 1 },
  { "from": "H", "to": "J", "value": 9 }
];

chart.dataFields.fromName = "from";
chart.dataFields.toName = "to";
chart.dataFields.value = "value";
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}

#chartdiv {
  width: 100%;
  height: 300px;
}
<script src="//www.amcharts.com/lib/4/core.js"></script>
<script src="//www.amcharts.com/lib/4/charts.js"></script>
<script src="//www.amcharts.com/lib/4/themes/animated.js"></script>
<div id="chartdiv"></div>