Skip to content

Commit 5794f88

Browse files
committed
Merge pull request #367 from githubfzq/fit-xlim-plot
fit plotting data to xlim
2 parents 5279df8 + 6c77514 commit 5794f88

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

‎mprof.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,14 +431,18 @@ def plot_file(filename, index=0, timestamps=True, children=True, options=None):
431431

432432
mem = np.asarray(mem)
433433
t = np.asarray(t)
434+
global_start = t[0]
435+
t = t - global_start
436+
437+
if options.xlim is not None:
438+
cond = (t >= options.xlim[0]) & (t <= options.xlim[1])
439+
mem, t = mem[cond], t[cond]
440+
434441
ind = t.argsort()
435442
mem = mem[ind]
436443
t = t[ind]
437444

438445
# Plot curves
439-
global_start = float(t[0])
440-
t = t - global_start
441-
442446
max_mem = mem.max()
443447
max_mem_ind = mem.argmax()
444448

0 commit comments

Comments
 (0)