pke1029 / open-chord

OpenChord is a Python library for creating chord diagrams.
GNU General Public License v3.0
8 stars 4 forks source link

How do we know the direction of the flow from the diagram produced #1

Open TomHsiung opened 2 months ago

TomHsiung commented 2 months ago

Hello, sir or madam

Thank you for creating this wonderful library for Python. Now I have made my own chord diagram via openchord. But I am confused about the interpretation of the diagram produced. How do we know the flow of the data? e.g., from source categories to target categories?

Regards,

Tom

pke1029 commented 2 months ago

Hi Tom,

I'm glad you find the library useful.

By default, the chord diagram displays a undirected graph. There's no concept of a source and a target. It only tells you the number of connections between two labels. (e.g. Emma and Ava shares 9 mutual friends.)

figure

However, a variation of the chord diagram known as the split chord diagram might be what you are looking for. You can plot this with fig = ocd.Split(adjacency_matrix, split_loc=4) to separate the first four labels from the rest.

game2

The openchord.Split function is available in the GitHub repository (version 0.1.8) but I have not push it to PyPi.org because I'm still not satisfied with it. I will leave this issue open for now until I update PyPi.org.

TomHsiung commented 2 months ago

Hi, pal

It's kind of you to timely respond. That's great and I'm looking forward to your Python push. Many thanks.

Tom

TomHsiung commented 2 months ago

There's no concept of a source and a target.

According to some tests I made, I found the width of a specific partial circumference is proportional to the sample frequency of the target variable.

For instance, `import openchord as ocd import numpy as np matrix = [ [5, 11, 1, 11, 10], [2, 29, 3, 18, 15], [0, 1, 0, 1, 0], [5, 22, 0, 15, 10], [11, 15, 1, 5, 9] ] labels = ['Danger', 'Optimal', 'Over', 'Suboptimal', 'Under'] fig = ocd.Split(matrix, split_loc = 4) fig.radius = 200 fig.plot_area = {"x": -500, "y": -500, "w": 1000, "h": 1000}

fig.colormap = ['#636EFA', '#EF553B', '#00CC96', '#AB63FA', '#FFA15A', '#19D3F3', '#FF6692', '#B6E880']`

I made the discovery by changing the number in the above matrix. I remember when I changed the number 15 in the 2nd line to 5, the circle width of the category "Optimal" shrank. Therefore, I prostrate that the width of the circumference is determined by the frequency of the target variable (the labels vertically sorted in the matrix). What do you think?

matrix = [ [5, 11, 1, 11, 10], [2, 29, 3, 18, 15], [0, 1, 0, 1, 0], [5, 22, 0, 15, 10], [11, 15, 1, 5, 9] ] labels = ['Danger', 'Optimal', 'Over', 'Suboptimal', 'Under']