originalsouth / SankeyPlots.jl

A Sankey Diagram recipe for Plots.jl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SankeyPlots Build Status

This package provides a Plots.jl recipe for Sankey diagrams.

Installation

julia> ]

pkg> add SankeyPlots

Usage

using SankeyPlots

src = [1, 1, 1, 1, 2, 2, 2, 3, 4, 5]
dst = [6, 3, 7, 4, 3, 7, 4, 7, 8, 8]
weights = [0.1, 0.3, 0.5, 0.5, 0.2, 2.8, 1, 0.45, 4.5, 3.3]

sankey(src, dst, weights)

In addition to Plots.jl attributes the following keyword arguments are supported.

Keyword argument Default value Options
node_labels nothing AbstractVector{<:String}
node_colors nothing Vector of color specifications supported by Plots.jl or color palette
edge_color :gray Plots.jl supported color or color selection from connected nodes with :src, :dst or :gradient
label_position :inside :legend, :node, :left, :right, :top or :bottom
label_size 8 Int
compact false Bool
names = [
    "PV",
    "Electricity Buy",
    "Battery",
    "Heat pump",
    "Biomass",
    "Electricity Sell",
    "Electricity Demand",
    "Heat demand",
]
energy_colors = palette(:seaborn_colorblind)[[9, 10, 3, 5, 2, 8, 1, 4]]

sankey(
    src, dst, weights;
    node_labels=names,
    node_colors=energy_colors,
    edge_color=:gradient,
    label_position=:bottom,
    label_size=7,
    compact=true,
)

Acknowledgement

@oxinabox made this possible by implementing the algorithm that solves the layout in LayeredLayouts.jl.

About

A Sankey Diagram recipe for Plots.jl

License:MIT License


Languages

Language:Julia 100.0%