-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Colorby='frame' not working #177
Comments
I wonder if you are running it on an empty data set. The |
Oh, I did indeed forget to paste in the output. Color by particle works perfectly so I do not think it is an empty data set. Here is an example: IN: So it seems like matplotlib should be returning a figure but nothing is showing up. |
Huh, ok, the outputs I pasted in were not showing up. Deleted the brackets |
On Friday, October 24, 2014, superboywonder [email protected]
|
Can you upload images of what you are(n't) getting? There isn't quite enough here for me to sort this out... |
The line it is pointing to should be |
And this is already fixed on the master branch. |
I am a tad confused, what version of trackpy are you using and where did you get it from? Searching through the history I can not find any evidence of that line ever being there. The 'by frame plotting' was added in c62d86c and git blame on master shows that it has not been changed sense. |
Can we see |
<script src="https://gist.github.com/superboywonder/f5aaa3c61fed9a8bee4e.js"></script>
First time making a gist, let me know if that wasn't what you were looking for. |
MWE (that works) import numpy as np
import pandas as pd
from itertools import product
centers = product(range(10, 100, 10), repeat=2)
# make some synthetic data
N = 25
turns = 3
r = np.linspace(0, 2.5, N)
theta = np.linspace(0, 2 * np.pi * turns, N)
frame = np.arange(N)
x = np.sin(theta) * r
y = np.cos(theta) * r
# skeleton of data frame
df = pd.DataFrame({'x': [], 'y': [], 'frame': [], 'particle': []})
# load the synthetic data
for n, (x0, y0) in enumerate(centers):
l_df = pd.DataFrame({'x': x + x0, 'y': y + y0, 'frame': frame, 'particle': n})
df = df.append(l_df)
trackpy.plots.plot_traj(df, colorby='frame') |
I notice possible "gaps" in the trajectories. (There is data for Frame 2 On Mon, Oct 27, 2014 at 2:11 PM, Thomas A Caswell [email protected]
|
There very likely a lot of gaps in the trajectories. I am performing tracking on quantum dots, which inherently blink stochastically. @tacaswell that code works for me. |
It also isn't the gaps, if you drop every-other in the code above # load the synthetic data
for n, (x0, y0) in enumerate(centers):
l_df = pd.DataFrame({'x': x + x0, 'y': y + y0, 'frame': frame, 'particle': n})
df = df.append(l_df.loc[::2])
# mask = np.random.rand(N) < .95
# df = df.append(l_df.iloc[mask]) still works fine so it isn't the gaps... |
I played around a little more and the issue seems to be related to the number of frames that are analyzed. f = tp.batch(frames[:100], 11, minmass=10000, threshold=500) #~100 features per frame
t = tp.link_df(f, 5, memory=3)
tp.plot_traj(t, colorby='frame') that code works, but if I change the number of frames to 200 the problem comes back. I am performing tracking on a video of 600 frames. |
I suspect we are overtaxing matplotlib and/or your computer. Matplotlib uses many optimizations make make line-drawing fast and memory-efficient. But multi-color lines are not so well optimized -- this is why I have trackpy print a message warning the user that it will take awhile. As a crude workaround, you could make several plots and superimpose them. Color-by-frame is a nice feature to have, but it's not easy to implement it in matplotlib, and the way I did it is the best way I know of. For general use, I recommend |
I am a newbie for python and trackpy. I also encountered a similar problem. Instead of not plotting the lines with
I am not sure if it is a correct way to do it, but it solved my problem. |
@MTone92 Can you please open a pull request with that change? |
This fix was suggested here: soft-matter#177 (comment)
Hello everyone!
I am fairly new to python so perhaps this is a user error, but I cannot get colorby='frame' to work for trackpy.plot_traj function.
I either get axis centered around zero and not even getting to 1 pixel or, if I try and add labels the plot disappears, and my output is just something like this:
<matplotlib.figure.Figure at 0x3b73d9550>
If I am doing something wrong or I need to check something, any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered: