0

I am trying to add a function to the pycircos module written by ponnhide on https://github.com/ponnhide/pyCircos/blob/master/pycircos/pycircos.py. I tried to add a circular arrow in the circular plot, which is a patch collection from a ring and an arrow. However, when I call the function I put into the pycircos module in my python notebook, I get a very distorted shape, which has nothing to do with the ring (wedge) or the arrow (polygon).

I have integrated the following function from https://github.com/NaysanSaran/markov-chain/blob/master/notebooks/Drawing.ipynb in the following pycircos module:

def draw_self_loop(self, center=(0, 0), radius=500, facecolor='#2693de', edgecolor='#000000', theta1=-30, theta2=240):
    
        # Add the ring
        rwidth = 0.02
        ring = mpatches.Wedge(center, radius, theta1, theta2, width=rwidth)
        # Triangle edges
        offset = 0.02
        xcent  = center[0] - radius + (rwidth/2)
        left   = [xcent - offset, center[1]]
        right  = [xcent + offset, center[1]]
        bottom = [(left[0]+right[0])/2., center[1]-0.05]
        arrow  = plt.Polygon([left, right, bottom, left])
        p = PatchCollection(
            [ring, arrow], 
            edgecolor = edgecolor, 
            facecolor = facecolor
        )
        self.ax.add_collection(p)

In my python notebook, I have called the function from the class object "circle" at the second last line:

%matplotlib inline
import pycircos
import matplotlib.pyplot as plt
import collections
from Bio import SeqIO 
Garc    = pycircos.Garc
Gcircle = pycircos.Gcircle
arcList_size = []
arcList_name = []
circle = Gcircle(figsize=(8,8)) 
with open("BIM_data_general.txt") as f:
    f.readline()
    for line in f:
        line   = line.rstrip().split(",") 
        name   = line[0]
        length = int(line[-1]) 
        arc    = Garc(arc_id=name, size=length, interspace=2, raxis_range=(990,1000),
                      labelposition=50,facecolor="#FFFFFF",edgecolor="#FFFFFF",labelsize=15, label_visible=False)
        arcList_size.append(arc.size)
        arcList_name.append(arc.arc_id)
        circle.add_garc(arc) 
circle.set_garcs(0,360)
circle.draw_self_loop()
circle.figure

instead of this example enter image description here , I get this distorted shape enter image description here

0 Answers0