Skip to content

Commit

Permalink
fix doc images
Browse files Browse the repository at this point in the history
  • Loading branch information
wspr committed May 29, 2024
1 parent 5e1ba2a commit f9f94da
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ import ausankey as sky
sky.sankey(data)
```
which produces:
![Image with options](fruits_default.png)
![Image with options](interface/iface_fruits_default.png)

There are a ton of customisation options set using a keyval interface. See the [user interface documentation](interface/) for details.
40 changes: 20 additions & 20 deletions docs/interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import ausankey as sky
sky.sankey(data)
```
which produces:
![Image with options](fruits_default.png)
![Image with options](iface_fruits_default.png)


## Colours
Expand All @@ -54,7 +54,7 @@ You can customise the colours either by changing the Matplotlib colormap:
```
sky.sankey(data,colormap=“jet”)
```
![Image with options](fruits_jet.png)
![Image with options](iface_fruits_jet.png)

Or by manually choosing the colours:
```
Expand All @@ -67,15 +67,15 @@ color_dict = {
}
sky.sankey(data,color_dict=color_dict)
```
![Image with options](fruits_colordict.png)
![Image with options](iface_fruits_colordict.png)

You can combine both approaches to use a colour map for most of the nodes and then override only some of them manually. (I.e., the `color_dict` does not need to have entries for all of the labels.)

The opacity of the flows and nodes can be customised with `flow_alpha` and `node_alpha` respectively:
```
sky.sankey(data,flow_alpha=0.3)
```
![Image with options](fruits_alpha.png)
![Image with options](iface_fruits_alpha.png)


## Order of entries (sorting)
Expand All @@ -86,19 +86,19 @@ The entries can be sorted highest to lowest:
```
sky.sankey(data,sort=“top”)
```
![Image with options](fruits_sort_top.png)
![Image with options](iface_fruits_sort_top.png)

Or lowest to highest:
```
sky.sankey(data,sort=“bottom”)
```
![Image with options](fruits_sort_bot.png)
![Image with options](iface_fruits_sort_bot.png)

Or left in the order listed in the data:
```
sky.sankey(data,sort=“none”)
```
![Image with options](fruits_sort_none.png)
![Image with options](iface_fruits_sort_none.png)

The sort order of individual labels can be overidden using the `sort_dict`.
E.g., `sort_dict={“a”,0}` would sort label `a` to the bottom of each stage regardless of its weighted node values.
Expand All @@ -109,7 +109,7 @@ The vertical alignment of the diagram can be `”top”`, `”bottom”`, or `
```
sky.sankey(data,valign = “center”)
```
![Image with options](fruits_valign.png)
![Image with options](iface_fruits_valign.png)


## Labels
Expand All @@ -125,7 +125,7 @@ label_dict = {
}
sky.sankey(data,label_dict=label_dict)
```
![Image with options](fruits_labeldict.png)
![Image with options](iface_fruits_labeldict.png)

Note that the dictionary does not need to contain an entry for each label.

Expand All @@ -148,7 +148,7 @@ sky.sankey(
value_loc=[“none”,”none”,”none”],
)
```
![Image with options](frame3_labels.png)
![Image with options](iface_frame3_labels.png)

Repeating the labels can be redundant in cases where labels
are repeated/duplicated in successive stages. Label
Expand All @@ -162,7 +162,7 @@ sky.sankey(
label_duplicate=False,
)
```
![Image with options](frame3_labels_dup.png)
![Image with options](iface_frame3_labels_dup.png)


## Values
Expand Down Expand Up @@ -190,7 +190,7 @@ Titles for each column of data can be added:
```
sky.sankey(data,titles=[“Summer”,”Winter”])
```
![Image with options](fruits_titles.png)
![Image with options](iface_fruits_titles.png)

Titles can be placed `”top”`, `”bottom”`, or `”both”`:
```
Expand All @@ -199,7 +199,7 @@ sky.sankey(data,
title_side = “bottom”,
)
```
![Image with options](fruits_titles_bottom.png)
![Image with options](iface_fruits_titles_bottom.png)

Titles can also be placed “outside” the plot area, with default spacing intending to be placed outside the frame:
```
Expand All @@ -209,7 +209,7 @@ sky.sankey(data,
title_loc = “outer”,
)
```
![Image with options](fruits_titles_outer.png)
![Image with options](iface_fruits_titles_outer.png)


## Fonts
Expand All @@ -223,7 +223,7 @@ sky.sankey(data,
fontcolor=“red”,
)
```
![Image with options](fruits_fonts.png)
![Image with options](iface_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`, `title_font`, and `value_font` options, which override the settings above.
Expand All @@ -242,7 +242,7 @@ sky.sankey(
value_font = {“color”: “green”},
)
```
![Image with options](data3_fonts_fancy.png)
![Image with options](iface_data3_fonts_fancy.png)

Refer to [Matplotlib documentation](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.text.html) for available options.

Expand All @@ -256,7 +256,7 @@ Horizontal framing can be placed `”top”`, `”bottom”`, or `”both”`:
```
sky.sankey(data,frame_side = “both”)
```
![Image with options](fruits_frame.png)
![Image with options](iface_fruits_frame.png)

The frame can be coloured:
```
Expand All @@ -265,7 +265,7 @@ sky.sankey(data,
frame_color=“#62dcbe”,
)
```
![Image with options](fruits_frame_color.png)
![Image with options](iface_fruits_frame_color.png)


## Edges
Expand All @@ -283,7 +283,7 @@ sky.sankey(data3,
flow_alpha = 0.3,
)
```
![Image with options](frame3_edge.png)
![Image with options](iface_frame3_edge.png)


## Spacing
Expand All @@ -306,4 +306,4 @@ sky.sankey( data,
title_gap = 0.1 ,
)
```
![Image with options](fruits_spacing.png)
![Image with options](iface_fruits_spacing.png)
46 changes: 23 additions & 23 deletions docs/sankey_doc_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,60 +28,60 @@
plt.figure()
sky.sankey(data)
plt.show()
plt.savefig("fruits_default.png")
plt.savefig("iface_fruits_default.png")
plt.close()

plt.figure()
sky.sankey(data, colormap="jet")
plt.show()
plt.savefig("fruits_jet.png")
plt.savefig("iface_fruits_jet.png")
plt.close()

color_dict = {"apple": "#f71b1b", "blueberry": "#1b7ef7", "banana": "#f3f71b", "lime": "#12e23f", "orange": "#f78c1b"}

plt.figure()
sky.sankey(data, color_dict=color_dict)
plt.show()
plt.savefig("fruits_colordict.png")
plt.savefig("iface_fruits_colordict.png")
plt.close()

label_dict = {"apple": "Apple", "blueberry": "B'berry", "banana": "Banana", "lime": "Lime", "orange": "Orange"}

plt.figure()
sky.sankey(data, label_dict=label_dict)
plt.show()
plt.savefig("fruits_labeldict.png")
plt.savefig("iface_fruits_labeldict.png")
plt.close()


plt.figure()
sky.sankey(data, flow_alpha=0.3)
plt.show()
plt.savefig("fruits_alpha.png")
plt.savefig("iface_fruits_alpha.png")
plt.close()

plt.figure()
sky.sankey(data, sort="top")
plt.show()
plt.savefig("fruits_sort_top.png")
plt.savefig("iface_fruits_sort_top.png")
plt.close()

plt.figure()
sky.sankey(data, sort="bottom")
plt.show()
plt.savefig("fruits_sort_bot.png")
plt.savefig("iface_fruits_sort_bot.png")
plt.close()

plt.figure()
sky.sankey(data, sort="none")
plt.show()
plt.savefig("fruits_sort_none.png")
plt.savefig("iface_fruits_sort_none.png")
plt.close()

plt.figure()
sky.sankey(data, titles=["Summer", "Winter"])
plt.show()
plt.savefig("fruits_titles.png")
plt.savefig("iface_fruits_titles.png")
plt.close()

plt.figure()
Expand All @@ -91,7 +91,7 @@
title_side="bottom",
)
plt.show()
plt.savefig("fruits_titles_bottom.png")
plt.savefig("iface_fruits_titles_bottom.png")
plt.close()

plt.figure()
Expand All @@ -101,7 +101,7 @@
title_loc = "outer",
)
plt.show()
plt.savefig("fruits_titles_outer.png")
plt.savefig("iface_fruits_titles_outer.png")
plt.close()

plt.figure()
Expand All @@ -112,7 +112,7 @@
fontcolor="red",
)
plt.show()
plt.savefig("fruits_fonts.png")
plt.savefig("iface_fruits_fonts.png")
plt.close()

plt.figure(dpi=600)
Expand All @@ -128,19 +128,19 @@
value_font = {"color": "green"},
)
plt.show()
plt.savefig("data3_fonts_fancy.png")
plt.savefig("iface_data3_fonts_fancy.png")
plt.close()

plt.figure()
sky.sankey(data, valign="center")
plt.show()
plt.savefig("fruits_valign.png")
plt.savefig("iface_fruits_valign.png")
plt.close()

plt.figure()
sky.sankey(data, frame_side="both")
plt.show()
plt.savefig("fruits_frame.png")
plt.savefig("iface_fruits_frame.png")
plt.close()

plt.figure()
Expand All @@ -149,7 +149,7 @@
frame_color="#62dcbe",
)
plt.show()
plt.savefig("fruits_frame_color.png")
plt.savefig("iface_fruits_frame_color.png")
plt.close()

plt.figure()
Expand All @@ -169,7 +169,7 @@
title_gap=0.1,
)
plt.show()
plt.savefig("fruits_spacing.png")
plt.savefig("iface_fruits_spacing.png")
plt.close()

data = pd.DataFrame(
Expand All @@ -186,7 +186,7 @@

plt.figure()
sky.sankey(data, sort="top", colormap="jet")
plt.savefig("frame2_sort_n1.png")
plt.savefig("iface_frame2_sort_n1.png")
plt.close()

color_dict = {
Expand All @@ -207,7 +207,7 @@
titles=["Stage 1", "Stage 2", "Stage 3"],
valign="center",
)
plt.savefig("frame3_pretty.png")
plt.savefig("iface_frame3_pretty.png")
plt.close()

plt.figure(dpi=600)
Expand All @@ -216,7 +216,7 @@
label_loc=["right","right","left"],
value_loc=["none","none","none"],
)
plt.savefig("frame3_labels.png")
plt.savefig("iface_frame3_labels.png")
plt.close()

plt.figure(dpi=600)
Expand All @@ -226,7 +226,7 @@
value_loc=["none","none","none"],
label_duplicate=False,
)
plt.savefig("frame3_labels_dup.png")
plt.savefig("iface_frame3_labels_dup.png")
plt.close()


Expand All @@ -250,7 +250,7 @@
valign="top",
)

plt.savefig("frame3_many.png")
plt.savefig("iface_frame3_many.png")
plt.close()

plt.figure(dpi=600)
Expand All @@ -263,7 +263,7 @@
node_lw = 2,
flow_lw = 1,
)
plt.savefig("frame3_edge.png")
plt.savefig("iface_frame3_edge.png")
plt.close()


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ dependencies = ["mkdocs", "mkdocstrings[python]"]
[tool.hatch.envs.doc.scripts]
ref = "mkdocs -v build"
img = "cd docs; python sankey_doc_examples.py; python example_plastics.py"
icp = "cd docs; cp -v *.png ../_site/; cp -v example_*.png ../_site/examples/"
icp = "cd docs; cp -v *.png ../_site/; cp -v example_*.png ../_site/examples/; cp -v iface_*.png ../_site/interface/ "


[tool.hatch.envs.test]
Expand Down

0 comments on commit f9f94da

Please sign in to comment.