.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_average_direction.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_average_direction.py: Average direction for each grid cell ==================================== See the flow between grid cells. .. GENERATED FROM PYTHON SOURCE LINES 6-10 .. code-block:: Python import traja df = traja.generate(seed=0) .. GENERATED FROM PYTHON SOURCE LINES 11-15 Average Flow (3D) ----------------- Flow can be plotted by specifying the `kind` parameter of :func:`traja.plotting.plot_flow` or by calling the respective functions. .. GENERATED FROM PYTHON SOURCE LINES 15-20 .. code-block:: Python import traja traja.plotting.plot_surface(df, bins=32) .. image-sg:: /gallery/images/sphx_glr_plot_average_direction_001.png :alt: plot average direction :srcset: /gallery/images/sphx_glr_plot_average_direction_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 21-25 Quiver ------ Quiver plot Additional arguments can be specified as a dictionary to `quiverplot_kws`. .. GENERATED FROM PYTHON SOURCE LINES 25-28 .. code-block:: Python traja.plotting.plot_quiver(df, bins=32) .. image-sg:: /gallery/images/sphx_glr_plot_average_direction_002.png :alt: plot average direction :srcset: /gallery/images/sphx_glr_plot_average_direction_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 29-34 Contour ------- Parameters `filled` and `quiver` are both enabled by default and can be disabled. Additional arguments can be specified as a dictionary to `contourplot_kws`. .. GENERATED FROM PYTHON SOURCE LINES 34-37 .. code-block:: Python traja.plotting.plot_contour(df, filled=False, quiver=False, bins=32) .. image-sg:: /gallery/images/sphx_glr_plot_average_direction_003.png :alt: plot average direction :srcset: /gallery/images/sphx_glr_plot_average_direction_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 38-40 Contour (Filled) ---------------- .. GENERATED FROM PYTHON SOURCE LINES 40-43 .. code-block:: Python traja.plotting.plot_contour(df, bins=32, contourfplot_kws={"cmap": "coolwarm"}) .. image-sg:: /gallery/images/sphx_glr_plot_average_direction_004.png :alt: plot average direction :srcset: /gallery/images/sphx_glr_plot_average_direction_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 44-48 Stream ------ 'cmap' can be specified, eg, 'coolwarm', 'viridis', etc. Additional arguments can be specified as a dictionary to 'streamplot_kws'. .. GENERATED FROM PYTHON SOURCE LINES 48-51 .. code-block:: Python traja.plotting.plot_stream(df, cmap="jet", bins=32) .. image-sg:: /gallery/images/sphx_glr_plot_average_direction_005.png :alt: plot average direction :srcset: /gallery/images/sphx_glr_plot_average_direction_005.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 52-54 Polar bar --------- .. GENERATED FROM PYTHON SOURCE LINES 54-56 .. code-block:: Python traja.plotting.polar_bar(df) .. image-sg:: /gallery/images/sphx_glr_plot_average_direction_006.png :alt: plot average direction :srcset: /gallery/images/sphx_glr_plot_average_direction_006.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/traja/checkouts/latest/traja/trajectory.py:1230: 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: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy trj.loc[mask, "heading"] = angle[mask] /home/docs/checkouts/readthedocs.org/user_builds/traja/checkouts/latest/traja/plotting.py:1228: 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: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy trj["turn_angle"] = feature_series /home/docs/checkouts/readthedocs.org/user_builds/traja/checkouts/latest/traja/frame.py:162: 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: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy self[name] = value /home/docs/checkouts/readthedocs.org/user_builds/traja/checkouts/latest/traja/plotting.py:1191: UserWarning: set_ticklabels() should only be used with a fixed number of ticks, i.e. after set_ticks() or using a FixedLocator. ax.set_xticklabels(["0", "45", "90", "135", "180", "-135", "-90", "-45"]) .. GENERATED FROM PYTHON SOURCE LINES 57-59 Polar bar (histogram) --------------------- .. GENERATED FROM PYTHON SOURCE LINES 59-60 .. code-block:: Python traja.plotting.polar_bar(df, overlap=False) .. image-sg:: /gallery/images/sphx_glr_plot_average_direction_007.png :alt: plot average direction :srcset: /gallery/images/sphx_glr_plot_average_direction_007.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/traja/checkouts/latest/traja/trajectory.py:1230: 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: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy trj.loc[mask, "heading"] = angle[mask] /home/docs/checkouts/readthedocs.org/user_builds/traja/checkouts/latest/traja/plotting.py:1228: 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: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy trj["turn_angle"] = feature_series /home/docs/checkouts/readthedocs.org/user_builds/traja/checkouts/latest/traja/frame.py:162: 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: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy self[name] = value /home/docs/checkouts/readthedocs.org/user_builds/traja/checkouts/latest/traja/plotting.py:1191: UserWarning: set_ticklabels() should only be used with a fixed number of ticks, i.e. after set_ticks() or using a FixedLocator. ax.set_xticklabels(["0", "45", "90", "135", "180", "-135", "-90", "-45"]) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.860 seconds) .. _sphx_glr_download_gallery_plot_average_direction.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_average_direction.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_average_direction.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_average_direction.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_