Skip to content

Commit

Permalink
Improve draw chart script, no vertial line label overcover
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Jan 19, 2024
1 parent 9f05dc5 commit 88bc4bb
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions devtools/block_sync/draw_sync_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def process_task(task):

import matplotlib.ticker as ticker

vlabels = []

for duration, height, label in results:
# for ckb_log_file, label in tasks:
# print("ckb_log_file: ", ckb_log_file)
Expand All @@ -103,24 +105,11 @@ def process_task(task):
ax.hlines([11_500_000], 0, max(duration), colors="gray", linestyles="dashed")

for i, h in enumerate(height):
if h % 1_000_000 == 0:
ax.vlines([duration[i]], 0, h, colors="gray", linestyles="dashed")

if i == len(height) -1 :
alabels.append(((duration[i],h),label))

if h == 11_000_000 or h == 11_500_000:
ax.vlines([duration[i]], 0, h, colors="black", linestyles="dashed")
voff=-60
if h == 11_000_000:
voff=-75
ax.annotate(round(duration[i],1),
fontsize=8,
xy=(duration[i], 0), xycoords='data',
xytext=(0, voff), textcoords='offset points',
bbox=dict(boxstyle="round", fc="0.9"),
arrowprops=dict(arrowstyle="-"),
horizontalalignment='center', verticalalignment='bottom')
if h == 11_500_000:
vlabels.append((duration[i],h))


ax.get_yaxis().get_major_formatter().set_scientific(False)
Expand Down Expand Up @@ -148,6 +137,7 @@ def process_task(task):

# sort alabsle by .0.1
alabels.sort(key=lambda x: x[0][0])
vlabels.sort(key=lambda x: x[0])

lheight=40
loffset=-40
Expand All @@ -167,6 +157,19 @@ def process_task(task):
elif loffset > 0:
lheight -= 20

for index, (duration, h) in enumerate(vlabels):
ax.vlines([duration], 0, h, colors="black", linestyles="dashed")
voff=-60
if index % 2 == 0:
voff=-75
ax.annotate(round(duration, 1),
fontsize=8,
xy=(duration, 0), xycoords='data',
xytext=(0, voff), textcoords='offset points',
bbox=dict(boxstyle="round", fc="0.9"),
arrowprops=dict(arrowstyle="-"),
horizontalalignment='center', verticalalignment='bottom')


plt.axhline(y=11_500_000, color='blue', linestyle='--')

Expand Down

0 comments on commit 88bc4bb

Please sign in to comment.