I tried drawing sankey plot using python (hv and bokeh) but was not able to get a plot with the TARGETS and SOURCE sorted in the desired order. My data "sorted_df0" is :
Source Target Value Category_links
31 SQUALIDAE DD 5 Data Deficient
35 PRISTIOPHORIDAE DD 2 Data Deficient
20 SPHYRNIDAE DD 1 Data Deficient
78 PSEUDOTRIAKIDAE DD 1 Data Deficient
102 ETMOPTERIDAE DD 1 Data Deficient
.. ... ... ... ...
27 TRIAKIDAE CE 5 Critically Endangered
39 SQUATINIDAE CE 2 Critically Endangered
87 CENTROPHORIDAE CE 1 Critically Endangered
72 MYLIOBATIDAE CE 1 Critically Endangered
14 CARCHARHINIDAE CE 4 Critically Endangered
Code is as below...
sankey2 = hv.Sankey(sorted_df0,kdims = ["Source", "Target"], vdims = ["Value"])
color_palette = cc.glasbey_dark[:len(sorted_df0)]
#Define options for the Sankey diagram
opts.defaults(opts.Sankey(edge_color=hv.Cycle(values=color_palette)))
plt.tight_layout()
sankey2.opts(cmap = "PuBuGn_r", label_position='outer',width=1000, height=700,title = "AAAA")
Resulting Sankey diagram But I need image with Targets in the order as given in the data frame that is DD, LC, NT, VU, EN, CE rather than the order in the plot