ExampleSankey_sample creates a simple sankey diagram. The output can be found at https://github.com/gonum/plot/blob/master/plotter/testdata/sankeySimple_golden.png.
()
| 22 | // ExampleSankey_sample creates a simple sankey diagram. |
| 23 | // The output can be found at https://github.com/gonum/plot/blob/master/plotter/testdata/sankeySimple_golden.png. |
| 24 | func ExampleSankey_simple() { |
| 25 | p := plot.New() |
| 26 | |
| 27 | // Define the stock categories |
| 28 | const ( |
| 29 | treeType int = iota |
| 30 | consumer |
| 31 | fate |
| 32 | ) |
| 33 | categoryLabels := []string{"Tree type", "Consumer", "Fate"} |
| 34 | |
| 35 | flows := []plotter.Flow{ |
| 36 | { |
| 37 | SourceCategory: treeType, |
| 38 | SourceLabel: "Large", |
| 39 | ReceptorCategory: consumer, |
| 40 | ReceptorLabel: "Mohamed", |
| 41 | Value: 5, |
| 42 | }, |
| 43 | { |
| 44 | SourceCategory: treeType, |
| 45 | SourceLabel: "Small", |
| 46 | ReceptorCategory: consumer, |
| 47 | ReceptorLabel: "Mohamed", |
| 48 | Value: 2, |
| 49 | }, |
| 50 | { |
| 51 | SourceCategory: treeType, |
| 52 | SourceLabel: "Large", |
| 53 | ReceptorCategory: consumer, |
| 54 | ReceptorLabel: "Sofia", |
| 55 | Value: 3, |
| 56 | }, |
| 57 | { |
| 58 | SourceCategory: treeType, |
| 59 | SourceLabel: "Small", |
| 60 | ReceptorCategory: consumer, |
| 61 | ReceptorLabel: "Sofia", |
| 62 | Value: 1, |
| 63 | }, |
| 64 | { |
| 65 | SourceCategory: treeType, |
| 66 | SourceLabel: "Large", |
| 67 | ReceptorCategory: consumer, |
| 68 | ReceptorLabel: "Wei", |
| 69 | Value: 6, |
| 70 | }, |
| 71 | { |
| 72 | SourceCategory: consumer, |
| 73 | SourceLabel: "Mohamed", |
| 74 | ReceptorCategory: fate, |
| 75 | ReceptorLabel: "Eaten", |
| 76 | Value: 6, |
| 77 | }, |
| 78 | { |
| 79 | SourceCategory: consumer, |
| 80 | SourceLabel: "Mohamed", |
| 81 | ReceptorCategory: fate, |