Skip to content

Commit

Permalink
fix logic for printing first/last labels
Browse files Browse the repository at this point in the history
  • Loading branch information
wspr committed Jun 3, 2024
1 parent fb4a925 commit 7ae8ce7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ausankey/ausankey.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Check failure on line 648 in ausankey/ausankey.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (T201)

ausankey.py:648:25: T201 `print` found
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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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")

Check failure on line 676 in ausankey/ausankey.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (T201)

ausankey.py:676:25: T201 `print` found
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)
Expand Down

0 comments on commit 7ae8ce7

Please sign in to comment.