.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_collection.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plot_collection.py: Plotting Multiple Trajectories ------------------------------ Plotting multiple trajectories is easy with :meth:`~traja.frame.TrajaCollection.plot`. .. GENERATED FROM PYTHON SOURCE LINES 6-22 .. image-sg:: /gallery/images/sphx_glr_plot_collection_001.png :alt: plot collection :srcset: /gallery/images/sphx_glr_plot_collection_001.png :class: sphx-glr-single-img .. code-block:: Python 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"} ) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.113 seconds) .. _sphx_glr_download_gallery_plot_collection.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_collection.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_collection.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_collection.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_