fixed text drawing on top of each other
This commit is contained in:
parent
152fe466f8
commit
cc8cb4805e
@ -101,7 +101,7 @@ class MemoryDrawer():
|
||||
return data
|
||||
|
||||
|
||||
def draw_diagram(data, vertical_gap_percentage=0.08, horizontal_gap=0.1):
|
||||
def draw_diagram(data, vertical_gap_percentage=0.12, horizontal_gap=0.1):
|
||||
tickpointers = []
|
||||
labels = pd.DataFrame()
|
||||
|
||||
@ -115,8 +115,6 @@ class MemoryDrawer():
|
||||
plot_bgcolor='#FFFFFF',
|
||||
)
|
||||
|
||||
extra_y = 0
|
||||
|
||||
for i, d in data.iterrows():
|
||||
fillcolor = random_color()
|
||||
data.at[i, 'fillcolor'] = fillcolor
|
||||
@ -127,10 +125,9 @@ class MemoryDrawer():
|
||||
|
||||
# Set base y values. Height of the rectangle.
|
||||
y0 = d['index']
|
||||
y1 = d['index']+1 # +(data['n_overlaps'].max() - data['n_overlaps'].min())
|
||||
y1 = d['index']+1
|
||||
|
||||
if d['overlap'] == True:
|
||||
# Count number of overlaps using overlapped_by
|
||||
n_overlaps = str(d['overlapped_by']).split(',')
|
||||
|
||||
# Row is overlapping the current row
|
||||
@ -139,18 +136,25 @@ class MemoryDrawer():
|
||||
y1 = sorted(map(int, d['overlapping'].split(',')))[-1] + 1
|
||||
|
||||
if pd.notna(d['overlapped_by']):
|
||||
y0 = y0 + vertical_gap_percentage
|
||||
y1 = y1 - vertical_gap_percentage
|
||||
y0 = y0
|
||||
y1 = y1
|
||||
x0 = x0 + (horizontal_gap*d['n_overlaps'])
|
||||
x1 = x1 - (horizontal_gap*d['n_overlaps'])
|
||||
|
||||
if d['partial_overlap'] == "Bottom":
|
||||
if pd.notna(d['partial_overlapped_by']):
|
||||
y0 = y0 + 0.25 + (0.6**len(d['partial_overlapped_by'].split(',')))
|
||||
if pd.notna(d['partial_overlapped_by']) and isinstance(d['partial_overlapped_by'], int):
|
||||
y0 = y0 + 0.25 + (0.6**n_overlaps)
|
||||
|
||||
if d['partial_overlap'] == "Top":
|
||||
if pd.notna(d['partial_overlapped_by']):
|
||||
y1 = y1 - (0.6**len(d['partial_overlapped_by'].split(',')))
|
||||
if pd.notna(d['partial_overlapped_by']) and isinstance(d['partial_overlapped_by'], int):
|
||||
y1 = y1 - (0.6**n_overlaps)
|
||||
|
||||
# Adjust y axis if there are multiple regions with the same end (otherwise would be drawn on top of each other)
|
||||
if i < data.size - 1:
|
||||
unique_end = data.loc[data['end'] == d['end']].reset_index(drop=True)
|
||||
print(d['name'])
|
||||
if len(unique_end) > 1:
|
||||
y1 = y1 - vertical_gap_percentage*(unique_end.loc[unique_end['name'] == d['name']].index[0]+1)
|
||||
|
||||
fig.add_shape(
|
||||
type="rect",
|
||||
|
Loading…
x
Reference in New Issue
Block a user