Plotting Multiple TrajectoriesΒΆ

Plotting multiple trajectories is easy with plot().

plot collection
import traja
from traja import TrajaCollection

# Create a dictionary of DataFrames, with 'id' as key.
dfs = {idx: traja.generate(idx, seed=idx) for idx in range(10, 15)}

# Create a TrajaCollection.
trjs = TrajaCollection(dfs)

# Note: A TrajaCollection can also be instantiated with a DataFrame, containing and id column,
# eg, TrajaCollection(df, id_col="id")

# 'colors' also allows substring matching, eg, {"car":"red", "person":"blue"}
lines = trjs.plot(
    colors={10: "red", 11: "blue", 12: "blue", 13: "orange", 14: "purple"}

Total running time of the script: ( 0 minutes 0.172 seconds)

Gallery generated by Sphinx-Gallery