Getting Started
# %pip install pycirclize
1-1. Set Sectors¶
The size of each data is required to set the sectors in a circular layout,
and the space size between sectors can also be set.
For example, if the data size of each sector is A=10, B=15, C=12, D=20, E=15
and
the space between sectors is 5 degrees
, it can be set up with the following code.
from pycirclize import Circos
# Initialize circos sectors
sectors = {"A": 10, "B": 15, "C": 12, "D": 20, "E": 15}
circos = Circos(sectors, space=5)
for sector in circos.sectors:
# Plot sector axis & name text
sector.axis(fc="none", ls="dashdot", lw=2, ec="black", alpha=0.5)
sector.text(f"Sector: {sector.name}={sector.size}", size=15)
fig = circos.plotfig()
From the data size of each sector and the space size between sectors, the appropriate circular layout of the sectors is set as shown in the figure above.
In addition, user can freely set the start-end degrees of the circular layout
in the range from -360 to 360. The following code is an example of setting start=-270
and end=30
.
from pycirclize import Circos
# Initialize circos sectors
sectors = {"A": 10, "B": 15, "C": 12, "D": 20, "E": 15}
circos = Circos(sectors, space=5, start=-270, end=30) # Set start-end degree ranges
for sector in circos.sectors:
# Plot sector axis & name text
sector.axis(fc="none", ls="dashdot", lw=2, ec="black", alpha=0.5)
sector.text(f"Sector: {sector.name}={sector.size}", size=15)
fig = circos.plotfig()
1-2. Set Tracks¶
User can freely place tracks within the sector radius range (0 - 100). The following code is an example of placing 3 tracks in each sector.
from pycirclize import Circos
# Initialize circos sectors
sectors = {"A": 10, "B": 15, "C": 12, "D": 20, "E": 15}
circos = Circos(sectors, space=5)
for sector in circos.sectors:
# Plot sector axis & name text
sector.axis(fc="none", ls="dashdot", lw=2, ec="black", alpha=0.5)
sector.text(f"Sector: {sector.name}={sector.size}", size=15)
# Set Track01 (Radius: 75 - 100)
track1 = sector.add_track((75, 100))
track1.axis(fc="tomato", alpha=0.5)
track1.text(track1.name)
# Set Track02 (Radius: 45 - 70)
track2 = sector.add_track((45, 70))
track2.axis(fc="cyan", alpha=0.5)
track2.text(track2.name)
# Set Track03 (Radius: 15 - 40)
track3 = sector.add_track((15, 40))
track3.axis(fc="lime", alpha=0.5)
track3.text(track3.name)
fig = circos.plotfig()