diff --git a/Project.toml b/Project.toml index 240349b..3587756 100644 --- a/Project.toml +++ b/Project.toml @@ -1,23 +1,21 @@ name = "SankeyPlots" uuid = "8fd88ec8-d95c-41fc-b299-05f2225f2cc5" authors = ["Daniel Schwabeneder and Davide Fioriti "] -version = "0.2.2" +version = "0.3.0" [deps] Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" LayeredLayouts = "f4a74d36-062a-4d48-97cd-1356bad1de4e" MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5" Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" -RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" [compat] -Graphs = "1.5" -LayeredLayouts = "0.2.4" -MetaGraphs = "0.7" -Plots = "1" -RecipesBase = "1" -julia = "1.5" +Graphs = "1.10" +LayeredLayouts = "0.2.10" +MetaGraphs = "0.8" +Plots = "1.35" +julia = "1" [extras] FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" diff --git a/README.md b/README.md index a4883db..71455ac 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,9 @@ pkg> add SankeyPlots ## Usage +The following examples describes how to create a Sankey diagram with the default settings. +The Sankey diagram is described by passing to the `sankey` function the source nodes `src`, destination nodes `dst`, and the weights `weights` of the edges. The nodes are indexed by integers starting from 1, and the size of the blocks and flows are proportional to the weights. + ```julia using SankeyPlots diff --git a/src/SankeyPlots.jl b/src/SankeyPlots.jl index 8b6e9bb..2e7b343 100644 --- a/src/SankeyPlots.jl +++ b/src/SankeyPlots.jl @@ -2,7 +2,6 @@ module SankeyPlots using LayeredLayouts using Plots -using RecipesBase using Graphs, MetaGraphs using SparseArrays @@ -37,8 +36,8 @@ In addition to [Plots.jl attributes](http://docs.juliaplots.org/latest/attribute label_position=:inside, label_size=8, compact=false, - force_layer::Vector{Pair{Int,Int}}=Vector{Pair{Int,Int}}(), - force_order::Vector{Pair{Int,Int}}=Vector{Pair{Int,Int}}(), + force_layer=Vector{Pair{Int,Int}}(), + force_order=Vector{Pair{Int,Int}}(), ) g = sankey_graph(s.args...) names = sankey_names(g, node_labels) @@ -197,7 +196,10 @@ In addition to [Plots.jl attributes](http://docs.juliaplots.org/latest/attribute primary := false framestyle --> :none - legend --> label_position === :legend ? :outertopright : false + legend --> label_position === :legend ? true : false + if label_position === :legend + legend_position --> :outertopright + end () end diff --git a/test/refs/edge_color_#789.png b/test/refs/edge_color_#789.png index 781135c..85bc28f 100644 Binary files a/test/refs/edge_color_#789.png and b/test/refs/edge_color_#789.png differ diff --git a/test/refs/edge_color_dst.png b/test/refs/edge_color_dst.png index 269cd0d..0b83b97 100644 Binary files a/test/refs/edge_color_dst.png and b/test/refs/edge_color_dst.png differ diff --git a/test/refs/edge_color_manual.png b/test/refs/edge_color_manual.png index 21c1376..ba5176c 100644 Binary files a/test/refs/edge_color_manual.png and b/test/refs/edge_color_manual.png differ diff --git a/test/refs/edge_color_src.png b/test/refs/edge_color_src.png index 88d451b..b87e947 100644 Binary files a/test/refs/edge_color_src.png and b/test/refs/edge_color_src.png differ diff --git a/test/refs/force_layer.png b/test/refs/force_layer.png index 5697960..ca4acaf 100644 Binary files a/test/refs/force_layer.png and b/test/refs/force_layer.png differ diff --git a/test/refs/force_order.png b/test/refs/force_order.png index bf718ee..7976576 100644 Binary files a/test/refs/force_order.png and b/test/refs/force_order.png differ diff --git a/test/refs/label_position_bottom.png b/test/refs/label_position_bottom.png index c6fba9d..1ed1a75 100644 Binary files a/test/refs/label_position_bottom.png and b/test/refs/label_position_bottom.png differ diff --git a/test/refs/label_position_left.png b/test/refs/label_position_left.png index 7f93cf2..b7e600e 100644 Binary files a/test/refs/label_position_left.png and b/test/refs/label_position_left.png differ diff --git a/test/refs/label_position_legend.png b/test/refs/label_position_legend.png index 4d3b242..a6c9ae4 100644 Binary files a/test/refs/label_position_legend.png and b/test/refs/label_position_legend.png differ diff --git a/test/refs/label_position_node.png b/test/refs/label_position_node.png index 1d93254..0dc6f8f 100644 Binary files a/test/refs/label_position_node.png and b/test/refs/label_position_node.png differ diff --git a/test/refs/label_position_right.png b/test/refs/label_position_right.png index aa7b4c8..0fbb450 100644 Binary files a/test/refs/label_position_right.png and b/test/refs/label_position_right.png differ diff --git a/test/refs/label_position_top.png b/test/refs/label_position_top.png index bed7a2e..8650ac5 100644 Binary files a/test/refs/label_position_top.png and b/test/refs/label_position_top.png differ diff --git a/test/refs/readme.png b/test/refs/readme.png index 4247766..c0fb9cf 100644 Binary files a/test/refs/readme.png and b/test/refs/readme.png differ diff --git a/test/refs/readme_kwargs.png b/test/refs/readme_kwargs.png index ecae6ee..afa9dff 100644 Binary files a/test/refs/readme_kwargs.png and b/test/refs/readme_kwargs.png differ diff --git a/test/runtests.jl b/test/runtests.jl index 1e979ce..7a1eae1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -87,7 +87,7 @@ energy_colors = palette(:seaborn_colorblind)[[9, 10, 3, 5, 2, 8, 1, 4]] @testset "force_order" begin @test_reference "refs/force_order.png" sankey( src, dst, weights; - force_order=[1=>5] # node 1 shall come before node 5 + force_order=[1=>2, 1=>5, 6=>3, 3=>4] # node 1 shall come before node 5 ) end end