Plot API Example
In [1]:
Copied!
# %pip install pycirclize
# %pip install pycirclize
1. Circos Class Plot¶
1-1. axis¶
In [2]:
Copied!
from pycirclize import Circos
sectors = {"A": 10, "B": 20, "C": 15}
circos = Circos(sectors, space=5)
circos.axis()
fig = circos.plotfig()
from pycirclize import Circos
sectors = {"A": 10, "B": 20, "C": 15}
circos = Circos(sectors, space=5)
circos.axis()
fig = circos.plotfig()
In [3]:
Copied!
from pycirclize import Circos
sectors = {"A": 10, "B": 20, "C": 15}
circos = Circos(sectors, end=270, space=5)
circos.axis(fc="lightgrey", ec="red")
fig = circos.plotfig()
from pycirclize import Circos
sectors = {"A": 10, "B": 20, "C": 15}
circos = Circos(sectors, end=270, space=5)
circos.axis(fc="lightgrey", ec="red")
fig = circos.plotfig()
1-2. text¶
In [4]:
Copied!
from pycirclize import Circos
import math
sectors = {"A": 10, "B": 20, "C": 15}
circos = Circos(sectors, space=5)
circos.text("center")
circos.text("top", r=100)
circos.text("right", r=100, deg=90)
circos.text("right-middle", r=50, deg=90)
circos.text("bottom", r=100, deg=180)
circos.text("left", r=100, deg=270)
circos.text("left-top", r=100 * math.sqrt(2), deg=315)
fig = circos.plotfig()
from pycirclize import Circos
import math
sectors = {"A": 10, "B": 20, "C": 15}
circos = Circos(sectors, space=5)
circos.text("center")
circos.text("top", r=100)
circos.text("right", r=100, deg=90)
circos.text("right-middle", r=50, deg=90)
circos.text("bottom", r=100, deg=180)
circos.text("left", r=100, deg=270)
circos.text("left-top", r=100 * math.sqrt(2), deg=315)
fig = circos.plotfig()
1-3. line¶
In [5]:
Copied!
from pycirclize import Circos
sectors = {"A": 10, "B": 20, "C": 15}
circos = Circos(sectors, space=5)
circos.line(r=100)
circos.line(r=80, deg_lim=(0, 270), color="red")
circos.line(r=60, deg_lim=(90, 360), color="blue", lw=3, ls="dotted")
fig = circos.plotfig()
from pycirclize import Circos
sectors = {"A": 10, "B": 20, "C": 15}
circos = Circos(sectors, space=5)
circos.line(r=100)
circos.line(r=80, deg_lim=(0, 270), color="red")
circos.line(r=60, deg_lim=(90, 360), color="blue", lw=3, ls="dotted")
fig = circos.plotfig()
1-4. rect¶
In [6]:
Copied!
from pycirclize import Circos
sectors = {"A": 10, "B": 20, "C": 15}
circos = Circos(sectors, space=5)
circos.rect(r_lim=(80, 100))
circos.rect(r_lim=(60, 80), deg_lim=(0, 270), fc="tomato")
circos.rect(r_lim=(30, 50), deg_lim=(90, 360), fc="lime", ec="grey", lw=2, hatch="//")
circos.rect(r_lim=(30, 100), deg_lim=(0, 90), fc="orange", alpha=0.2)
fig = circos.plotfig()
from pycirclize import Circos
sectors = {"A": 10, "B": 20, "C": 15}
circos = Circos(sectors, space=5)
circos.rect(r_lim=(80, 100))
circos.rect(r_lim=(60, 80), deg_lim=(0, 270), fc="tomato")
circos.rect(r_lim=(30, 50), deg_lim=(90, 360), fc="lime", ec="grey", lw=2, hatch="//")
circos.rect(r_lim=(30, 100), deg_lim=(0, 90), fc="orange", alpha=0.2)
fig = circos.plotfig()
1-5. link¶
In [7]:
Copied!
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 links in various styles
circos.link(("A", 0, 1), ("A", 7, 8))
circos.link(("A", 1, 2), ("A", 7, 6), color="skyblue")
circos.link(("A", 9, 10), ("B", 4, 3), direction=1, color="tomato")
circos.link(("B", 5, 7), ("C", 6, 8), direction=1, ec="black", lw=1, hatch="//")
circos.link(("B", 18, 16), ("B", 11, 13), r1=90, r2=90, color="violet", ec="red", lw=2, ls="dashed")
circos.link(("C", 1, 3), ("B", 2, 0), direction=1, color="limegreen")
circos.link(("C", 11.5, 14), ("A", 4, 3), direction=2, color="chocolate", ec="black", lw=1, ls="dotted")
fig = circos.plotfig()
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 links in various styles
circos.link(("A", 0, 1), ("A", 7, 8))
circos.link(("A", 1, 2), ("A", 7, 6), color="skyblue")
circos.link(("A", 9, 10), ("B", 4, 3), direction=1, color="tomato")
circos.link(("B", 5, 7), ("C", 6, 8), direction=1, ec="black", lw=1, hatch="//")
circos.link(("B", 18, 16), ("B", 11, 13), r1=90, r2=90, color="violet", ec="red", lw=2, ls="dashed")
circos.link(("C", 1, 3), ("B", 2, 0), direction=1, color="limegreen")
circos.link(("C", 11.5, 14), ("A", 4, 3), direction=2, color="chocolate", ec="black", lw=1, ls="dotted")
fig = circos.plotfig()