-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Making the color of external nodes to be the same as its corresponding Arcs color to destination #36
Comments
Hi @NaifahNurya, It seems like you can do what you want by converting the matrix dataframe to a transposed matrix and setting link direction=1. from pycirclize import Circos
import pandas as pd
df = pd.read_csv('deliveredparcel.csv', index_col=0)
df.index.name = None
# Initialize Circos from matrix for plotting Chord Diagram
circos = Circos.initialize_from_matrix(
- df,
+ df.T # Convert to transposed matrix
space=5,
cmap="tab10",#"viridis", or "tab10"
ticks_interval=100,
label_kws=dict(size=12),#label_kws=dict(size=12, r=110),
- link_kws=dict(ec="black", lw=0.5, direction=-1),
+ link_kws=dict(ec="black", lw=0.5, direction=1), # Set direcion=1
)
circos.savefig("example07.png")
fig = circos.plotfig() If it doesn't work, please provide the |
Some how it works but not 100%, because the color of the arc not exactly the same as the color of the external node (which is a source). As you can see the figure in the attached file. For example, from City4 to City5 (the color of external node "City5" is dark gray, but its corresponding arc is light gray, however it is required to be dark gray). The same to City, City7 and City8 their color is dark but their corresponding arc from it as a source is a light. Also I provide deliveredparcel.csv] for reference as requested. |
Unfortunately, Example Code: Link color alpha = 1.0 from pycirclize import Circos
import pandas as pd
df = pd.read_csv('deliveredparcel.csv', index_col=0)
df.index.name = None
# Initialize Circos from matrix for plotting Chord Diagram
circos = Circos.initialize_from_matrix(
df.T,
space=5,
cmap="tab10",
ticks_interval=100,
label_kws=dict(size=12),
link_kws=dict(ec="black", lw=0.5, direction=1, alpha=1.0), # Set alpha=1.0, by default 0.5
)
circos.savefig("example07.png")
fig = circos.plotfig() example07.png |
Thank you @moshi4 , now it looks as required. One more thing, Is there a means of labelling a % of each arc from source to destination, Calculated over the all arc (entire dataset). I checked on the documentation [https://moshi4.github.io/pyCirclize/] but I didn't find it. |
pyCirclize does not have this functionality. |
Okay, thank you for your feedback. @moshi4 |
@moshi4 , I have another question. I want to use the alpha value in the cmap. However when I applied it I got an error. Using the same code as an example, in the "link_kws" it works fine, but in the "cmap" It rises an error. My intention to use the same alpha value in both "link_kws" and "cmap", The following is the error which I got " File "C:\Users\admin\anaconda3\envs\pycirclize\lib\site-packages\pycirclize\circos.py", line 262, in initialize_from_matrix Any solution/suggestion?
|
|
Thank you for reply @moshi4 . So, how to resolve the issue? To make the transparency of the sector to be the same as the transparency of its corresponding link (arc)? Because for the link we can set it in |
It may be possible to solve this problem by directly rewriting the code of pyCirclize/src/pycirclize/circos.py Line 271 in 131900c
- outer_track.axis(fc=color)
+ outer_track.axis(fc=color, alpha=0.8) |
Thank you @moshi4 |
Thank you for this library which is easy to use. I use the following code to show the parcel source and destination.
The final output is shown in the figure below (see attached file). Is there a way to modify the code so that the color of the external nodes matches the color of their corresponding arcs if those arcs are the sources? For example, in the figure, the external node "City4" has a green color, and since it is the source city delivering to "City5," the color of the corresponding arc (because it is the source) should also be green to match its external node. In summary, the color of the arc should be determined by the color of its corresponding "source" external node.
The text was updated successfully, but these errors were encountered: