moshi4 / pyCirclize

Circular visualization in Python (Circos Plot, Chord Diagram, Radar Chart)
https://moshi4.github.io/pyCirclize/
MIT License
758 stars 47 forks source link

Arrows #45

Closed dnjst closed 10 months ago

dnjst commented 10 months ago

This is a terrific package!

I was wondering, when calling circos.link(), is there a way to draw a black arrow with the line in the middle and arrowhead located in the middle of the sector/region I call it from, rather than the wide chords or arrows? like -----> or Figure 3.23 in this link: https://jokergoo.github.io/circlize_book/book/graphics.html#circular-arrows

Thanks

moshi4 commented 10 months ago

Hi @dnjst,

is there a way to draw a black arrow with the line in the middle and arrowhead located in the middle of the sector/region

Currently, pyCirclize does not have this functionality. I think it is not difficult to implement, so I will consider adding it at the next release.

moshi4 commented 10 months ago

circos.link_line() method is added in the newly released pyCirclize v1.2.0.

Code Example

from pycirclize import Circos

sectors = {"A": 10, "B": 20, "C": 15}
name2color = {"A": "red", "B": "blue", "C": "green"}
circos = Circos(sectors, space=5)
for sector in circos.sectors:
    track = sector.add_track((95, 100))
    track.axis(fc=name2color[sector.name])
    track.text(sector.name, color="white", size=12)
    track.xticks_by_interval(1)

# Plot link lines in various styles
circos.link_line(("A", 0), ("A", 7))
circos.link_line(("A", 9), ("B", 3), direction=1, color="red")
circos.link_line(("B", 5), ("B", 7), direction=-1, color="blue", lw=1.0)
circos.link_line(("B", 8), ("B", 15), r1=90, r2=90, direction=2, color="green", ls="dashed")

circos.link(("B", 17, 19), ("C", 11, 9), color="black")
circos.link_line(("B", 18), ("C", 10), direction=1, arrow_height=6, arrow_width=4, color="white", lw=1.0)

circos.savefig("example.png")

example.png

example