Skip to content

Commit 075de73

Browse files
author
Armand Foucault
committed
Improved grid and layout
1 parent 9ecdd47 commit 075de73

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

mprof.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ def flame_plotter(filename, index=0, timestamps=True, children=True, options=Non
492492
ind = t.argsort()
493493
mem = mem[ind]
494494
t = t[ind]
495+
495496
stack_size = 1 + max(ex[4] for executions in ts.values() for ex in executions)
496497
def level_to_saturation(level):
497498
return 1 - 0.75 * level / stack_size
@@ -516,15 +517,17 @@ def level_to_saturation(level):
516517
time.localtime(global_start)) \
517518
+ ".{0:03d}".format(int(round(math.modf(global_start)[0] * 1000)))
518519

519-
pl.plot(t, mem, "+-" + mem_line_colors[index % len(mem_line_colors)],
520+
pl.plot(t, mem, "-" + mem_line_colors[index % len(mem_line_colors)],
520521
label=mem_line_label)
521522

522523
bottom, top = pl.ylim()
523524
bottom += 0.001
524525
top -= 0.001
525526

527+
pl.gca().grid(True)
526528
timestamp_ax = pl.twinx()
527529
timestamp_ax.set_ylim((0, stack_size))
530+
timestamp_ax.grid(False)
528531

529532
# plot children, if any
530533
if len(chld) > 0 and children:
@@ -578,8 +581,6 @@ def level_to_saturation(level):
578581
def add_timestamp_rectangle(ax, x0, x1, y0, y1, *, xshift=0, color='none'):
579582
x0 -= xshift
580583
x1 -= xshift
581-
print(f"Drawing rectangle ({x0}, {y0}, {x1}, {y1})")
582-
print(color)
583584
ax.fill_betweenx((y0, y1), x0, x1, color=color, alpha=0.5, linewidth=1)
584585

585586

@@ -682,7 +683,10 @@ def xlim_type(value):
682683
sys.exit(-1)
683684

684685
fig = pl.figure(figsize=(14, 6), dpi=90)
685-
ax = fig.add_axes([0.1, 0.1, 0.6, 0.75])
686+
if not args.flame_mode:
687+
ax = fig.add_axes([0.1, 0.1, 0.6, 0.75])
688+
else:
689+
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
686690
if args.xlim is not None:
687691
pl.xlim(args.xlim[0], args.xlim[1])
688692

@@ -706,9 +710,11 @@ def xlim_type(value):
706710

707711
# place legend within the plot, make partially transparent in
708712
# case it obscures part of the lineplot
709-
leg = ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
710-
leg.get_frame().set_alpha(0.5)
711-
pl.grid()
713+
if not args.flame_mode:
714+
leg = ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
715+
leg.get_frame().set_alpha(0.5)
716+
pl.grid()
717+
712718
if args.output:
713719
pl.savefig(args.output)
714720
else:

0 commit comments

Comments
 (0)