From 6bfcc6852ca7f740318c03c0fffa0074cd5159a6 Mon Sep 17 00:00:00 2001 From: Will Robertson Date: Tue, 2 Apr 2024 09:56:12 +1030 Subject: [PATCH] doc --- docs/index.md | 24 +++++++++++++++--------- docs/sankey_doc_examples.py | 17 +++++++++-------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/docs/index.md b/docs/index.md index 4844462..6510571 100644 --- a/docs/index.md +++ b/docs/index.md @@ -124,6 +124,13 @@ sky.sankey(data,sort=“none”) ``` ![Image with options](fruits_sort_none.png) +## Vertical Alignment + +The vertical alignment of the diagram can be `”top”`, `”bottom”`, or `”center”`: +``` +sky.sankey(data,valign = “center”) +``` +![Image with options](fruits_valign.png) ## Labels @@ -151,16 +158,19 @@ Allowable values for `` and `` are `"left"`, `"right"`, `"center" label_loc = [ "left", "none", "right" ] - +When adjusting the position of the labels, some care +can be needed to avoid clashing with the printing +of the values. In these examples we just turn the values off. ``` sky.sankey( data3, label_loc=["right","right","left"], + value_loc=["none","none","none"], ) ``` ![Image with options](frame3_labels.png) -Repeating the labels can he redundant in cases where labels +Repeating the labels can be redundant in cases where labels are repeated/duplicated in successive stages. Label duplication can be turned off, which only prints a label if it didn't appear in the previous stage. @@ -168,6 +178,7 @@ if it didn't appear in the previous stage. sky.sankey( data3, label_loc=["right","right","left"], + value_loc=["none","none","none"], label_duplicate=False, ) ``` @@ -216,7 +227,7 @@ sky.sankey(data, ![Image with options](fruits_fonts.png) These options do not use `snake_case` for consistency with their underlying Matplotlib options. -Further font options can be passed through directly via the `label_font` and `title_font` options, which override the settings above. +Further font options can be passed through directly via the `label_font`, `title_font`, and `value_font` options, which override the settings above. For example: ``` @@ -229,6 +240,7 @@ sky.sankey( “fontweight”: “bold”, }, label_font = {“color”: “blue”}, + value_font = {“color”: “green”}, ) ``` ![Image with options](data3_fonts_fancy.png) @@ -236,13 +248,7 @@ sky.sankey( Refer to [Matplotlib documentation](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.text.html) for available options. -## Vertical Alignment -The vertical alignment of the diagram can be `"top"`, `"bottom"`, or `"center"`: -``` -sky.sankey(data,valign = "center") -``` -![Image with options](fruits_valign.png) ## Frames diff --git a/docs/sankey_doc_examples.py b/docs/sankey_doc_examples.py index d51e725..1540f91 100644 --- a/docs/sankey_doc_examples.py +++ b/docs/sankey_doc_examples.py @@ -3,14 +3,6 @@ import ausankey as sky -data = pd.read_csv("../tests/fruit.csv") - -plt.figure() -sky.sankey(data) -plt.show() -plt.savefig("fruits_default.png") -plt.close() - data = pd.DataFrame( [ ("apple", 100, "apple", 50), @@ -33,6 +25,12 @@ ] ) +plt.figure() +sky.sankey(data) +plt.show() +plt.savefig("fruits_default.png") +plt.close() + plt.figure() sky.sankey(data, colormap="jet") plt.show() @@ -127,6 +125,7 @@ "fontweight": "bold", }, label_font = {"color": "blue"}, + value_font = {"color": "green"}, ) plt.show() plt.savefig("data3_fonts_fancy.png") @@ -215,6 +214,7 @@ sky.sankey( data3, label_loc=["right","right","left"], + value_loc=["none","none","none"], ) plt.savefig("frame3_labels.png") plt.close() @@ -223,6 +223,7 @@ sky.sankey( data3, label_loc=["right","right","left"], + value_loc=["none","none","none"], label_duplicate=False, ) plt.savefig("frame3_labels_dup.png")