From 7ae8ce778fe5e3e29cf2b208dd60e1aa1101f888 Mon Sep 17 00:00:00 2001 From: Will Robertson Date: Mon, 3 Jun 2024 20:24:32 +0930 Subject: [PATCH] fix logic for printing first/last labels --- ausankey/ausankey.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ausankey/ausankey.py b/ausankey/ausankey.py index 7eee1a4..4635543 100644 --- a/ausankey/ausankey.py +++ b/ausankey/ausankey.py @@ -636,13 +636,16 @@ def subplot(self, ii): # Draw node labels for lr in [0, 1] if ii == 0 else [1]: + + label_bool = ii + lr == 0 or ii + lr == self.num_flow or self.label_duplicate loc = self.label_loc[ii + lr] # inside labels, left if loc in ("left", "both"): xx = x_lr[lr] - self.x_label_gap + (lr - 1) * self.x_node_width for label in self.node_sizes[ii + lr]: - if (label not in self.node_sizes[ii]) or self.label_duplicate: + if label_bool or label not in self.node_sizes[ii]: + print(ii+lr,label_bool,"left") val = self.node_sizes[ii + lr][label] yy = self.node_pos_bot[ii][lr][label] + val / 2 self.draw_label(xx, yy, label, "right", val) @@ -651,7 +654,7 @@ def subplot(self, ii): if loc in ("center"): xx = x_lr[lr] + (2 * lr - 1) * self.x_node_width / 2 for label in self.node_sizes[ii + lr]: - if (label not in self.node_sizes[ii]) or self.label_duplicate: + if label_bool or label not in self.node_sizes[ii]: val = self.node_sizes[ii + lr][label] yy = self.node_pos_bot[ii][lr][label] + val / 2 self.draw_label(xx, yy, label, "center", val) @@ -660,7 +663,7 @@ def subplot(self, ii): if loc in ("top"): xx = x_lr[lr] + (2 * lr - 1) * self.x_node_width / 2 for label in self.node_sizes[ii + lr]: - if (label not in self.node_sizes[ii]) or self.label_duplicate: + if label_bool or label not in self.node_sizes[ii]: val = self.node_sizes[ii + lr][label] yy = self.node_pos_bot[ii][lr][label] + val + self.y_label_gap self.draw_label(xx, yy, label, "center", val) @@ -669,7 +672,8 @@ def subplot(self, ii): if loc in ("right", "both"): xx = x_lr[lr] + self.x_label_gap + lr * self.x_node_width for label in self.node_sizes[ii + lr]: - if (label not in self.node_sizes[ii]) or self.label_duplicate: + if label_bool or label not in self.node_sizes[ii]: + print(ii+lr,label_bool,"right") val = self.node_sizes[ii + lr][label] yy = self.node_pos_bot[ii][lr][label] + val / 2 self.draw_label(xx, yy, label, "left", val)