Skip to content

Add colorbar and an option to plot the velocities to plot_traj()#800

Open
T0T0R wants to merge 1 commit into
soft-matter:masterfrom
T0T0R:master
Open

Add colorbar and an option to plot the velocities to plot_traj()#800
T0T0R wants to merge 1 commit into
soft-matter:masterfrom
T0T0R:master

Conversation

@T0T0R

@T0T0R T0T0R commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

A color bar can now be added when plotting the trajectories, which is helpful with colorby='frame'. The title of this colorbar can be selected between "Frame number" or "Time (s)".
Example with tp.plot_traj(t, mpp=1.0, fps=24, colorby='frame', cmap='cividis', colorbar_units='frames', superimpose=background):
02

Example with tp.plot_traj(t, mpp=1.0, fps=24, colorby='frame', cmap='cividis', colorbar_units='real', superimpose=background):
01

Another feature is added, colorby='velocity' allowing to color the trajectories by the speed of the objects. The title of the color bar can be selected between "Speed (px/s)" or "Speed (µm/s)".
Example with tp.plot_traj(t, mpp=1.0, fps=24, colorby='velocity', cmap='inferno', colorbar_units='frames', superimpose=background);:
04

Example with tp.plot_traj(t, mpp=1.0, fps=24, colorby='velocity', cmap='inferno', colorbar_units='real', superimpose=background);:
03

@nkeim nkeim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this pull request! In the interest of keeping trackpy's API simple and memorable, I wonder if the colorbar_units argument is really necessary. It should be possible to choose the units automatically based on whether mpp or fps (or both) are given, which is currently the behavior for the position axes. This also avoids the ambiguity of the half-real units µm/frame and px/s.

Also, the current master branch fixes the automated checks which would be helpful for testing. If you're comfortable with rebasing this PR, please do so; no worries if not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants