Full documentation is available at traja.readthedocs.io.
!pip install traja
import traja
# Create sample random walk
df = traja.generate()
# Visualize x and y values with built-in pandas methods
df.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x11f75d668>
.traja.plot()
)¶fig = df.traja.plot()
df.traja.calc_angle().hist() # with regard to x-axis
<matplotlib.axes._subplots.AxesSubplot at 0x1203a3ac8>
df.traja.calc_turn_angle().hist() # deviation from strait ahead
<matplotlib.axes._subplots.AxesSubplot at 0x120f85518>
for kind in ['stream', 'quiver', 'contourf']:
fig = df.traja.plot_flow(kind=kind)
df.traja.calc_turn_angle().plot()
<matplotlib.axes._subplots.AxesSubplot at 0x120f8f1d0>
for log in [True, False]:
for bins in [8, 32]:
print(f"Bins: {bins}")
df.traja.trip_grid(bins=bins, log=log)
Bins: 8
Bins: 32
Bins: 8
Bins: 32
traja.plotting.polar_bar(df)
/Users/justinshenk/Projects/mousetrack/traja/plotting.py:745: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy trj["turn_angle"] = feature_series /Users/justinshenk/anaconda3/envs/traja/lib/python3.6/site-packages/pandas/core/generic.py:5096: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy self[name] = value
<matplotlib.axes._subplots.PolarAxesSubplot at 0x1204025f8>
# Show non-overlapping histogram
traja.plotting.polar_bar(df, overlap=False)
/Users/justinshenk/Projects/mousetrack/traja/plotting.py:745: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy trj["turn_angle"] = feature_series /Users/justinshenk/anaconda3/envs/traja/lib/python3.6/site-packages/pandas/core/generic.py:5096: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy self[name] = value
<matplotlib.axes._subplots.PolarAxesSubplot at 0x120aa7d30>
# Resample to arbitrary step length (here, 20 meters)
fig = df.traja.rediscretize(R=20).traja.plot()
# Resample to arbitrary time (here, 1 second)
fig = df.traja.resample_time(step_time='1s').traja.plot()