Skip to content

Commit

Permalink
Do not plot zero-width chords (#17)
Browse files Browse the repository at this point in the history
Co-authored-by: Tanguy Fardet <Silmathoron@users.noreply.github.com>
  • Loading branch information
gph82 and Silmathoron authored Nov 25, 2020
1 parent 1b211cd commit 84d5610
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions chord_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,10 @@ def chord_diagram(mat, names=None, order=None, width=0.1, pad=2., gap=0.03,

start, end = pos[(i, i)]

self_chord_arc(start, end, radius=1 - width - gap,
chordwidth=0.7*chordwidth, color=colors[i],
alpha=alpha, ax=ax)
if mat[i, i] > 0:
self_chord_arc(start, end, radius=1 - width - gap,
chordwidth=0.7*chordwidth, color=colors[i],
alpha=alpha, ax=ax)

color = colors[i]

Expand All @@ -204,10 +205,10 @@ def chord_diagram(mat, names=None, order=None, width=0.1, pad=2., gap=0.03,

start1, end1 = pos[(i, j)]
start2, end2 = pos[(j, i)]

chord_arc(start1, end1, start2, end2, radius=1 - width - gap,
chordwidth=chordwidth, color=colors[i], cend=cend,
alpha=alpha, ax=ax, use_gradient=use_gradient)
if mat[i, j] > 0 or mat[j, i] > 0:
chord_arc(start1, end1, start2, end2, radius=1 - width - gap,
chordwidth=chordwidth, color=colors[i], cend=cend,
alpha=alpha, ax=ax, use_gradient=use_gradient)

# add names if necessary
if names is not None:
Expand Down

0 comments on commit 84d5610

Please sign in to comment.