From 73ded3a8a4197cf2a879bc25e8087f088929507b Mon Sep 17 00:00:00 2001 From: Ron Shnapp Date: Wed, 23 Oct 2024 09:41:59 +0300 Subject: [PATCH] added color to trajectory plots --- myptv/makePlots/plot_trajectories.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/myptv/makePlots/plot_trajectories.py b/myptv/makePlots/plot_trajectories.py index 3b416bf..89e8ad6 100755 --- a/myptv/makePlots/plot_trajectories.py +++ b/myptv/makePlots/plot_trajectories.py @@ -37,6 +37,13 @@ def plot_trajectories(fname, min_length, write_trajID=False, t0=0, te=-1): trajectories = dict([(g, array(k.values)) for g,k in data.groupby(0) if g!=-1]) + xmax = amax(data[1]) + xmin = amin(data[1]) + ymax = amax(data[2]) + ymin = amin(data[2]) + zmax = amax(data[3]) + zmin = amin(data[3]) + fig = plt.figure() ax = fig.add_subplot(projection='3d') @@ -72,7 +79,10 @@ def plot_trajectories(fname, min_length, write_trajID=False, t0=0, te=-1): xs = trajectories[id_][i0:ie,1] ys = trajectories[id_][i0:ie,2] zs = trajectories[id_][i0:ie,3] - l = ax.plot(xs, zs, ys, 'o-', ms=1, lw=0.5) + c = (1-(xs[0]-xmin)/(xmax-xmin)*0.97, + (ys[1]-ymin)/(ymax-ymin)*0.97, + (zs[2]-zmin)/(zmax-zmin)*0.97) + l = ax.plot(xs, zs, ys, 'o-', ms=1, lw=0.5, color=c) xm.append(amin(xs)) ; xm.append(amax(xs)) ym.append(amin(ys)) ; ym.append(amax(ys))