Plotting Grid Cell Flow

Trajectories can be discretized into grid cells and the average flow from each grid cell to its neighbor can be plotted with plot_flow(), eg:

traja.plot_flow(df, kind='stream')

plot_flow() kind Arguments

See the gallery for more examples.

3D Surface Plot

traja.plotting.plot_surface(trj: traja.frame.TrajaDataFrame, bins: Union[int, tuple, None] = None, cmap: str = 'viridis', **surfaceplot_kws) → matplotlib.figure.Figure[source]

Plot surface of flow from each grid cell to neighbor in 3D.

Parameters:
  • bins (int or tuple) – Tuple of x,y bin counts; if bins is int, bin count of x, with y inferred from aspect ratio
  • cmap (str) – color map
  • surfaceplot_kws – Additional keyword arguments for plot_surface()
Returns:

Axes of quiver plot

Return type:

ax (Axes)

3D plot

Quiver Plot

traja.plotting.plot_quiver(trj: traja.frame.TrajaDataFrame, bins: Union[int, tuple, None] = None, quiverplot_kws: dict = {}, **kwargs) → matplotlib.axes._axes.Axes[source]

Plot average flow from each grid cell to neighbor.

Parameters:
  • bins (int or tuple) – Tuple of x,y bin counts; if bins is int, bin count of x, with y inferred from aspect ratio
  • quiverplot_kws – Additional keyword arguments for quiver()
Returns:

Axes of quiver plot

Return type:

ax (Axes)

traja.plot_quiver(df, bins=32)
quiver plot

Contour Plot

traja.plotting.plot_contour(trj: traja.frame.TrajaDataFrame, bins: Union[int, tuple, None] = None, filled: bool = True, quiver: bool = True, contourplot_kws: dict = {}, contourfplot_kws: dict = {}, quiverplot_kws: dict = {}, ax: matplotlib.axes._axes.Axes = None, **kwargs) → matplotlib.axes._axes.Axes[source]

Plot average flow from each grid cell to neighbor.

Parameters:
  • trj – Traja DataFrame
  • bins (int or tuple) – Tuple of x,y bin counts; if bins is int, bin count of x, with y inferred from aspect ratio
  • filled (bool) – Contours filled
  • quiver (bool) – Quiver plot
  • contourplot_kws – Additional keyword arguments for contour()
  • contourfplot_kws – Additional keyword arguments for contourf()
  • quiverplot_kws – Additional keyword arguments for quiver()
  • ax (optional) – Matplotlib Axes
Returns:

Axes of quiver plot

Return type:

ax (Axes)

traja.plot_contour(df, filled=False, quiver=False, bins=32)
contour plot

Contour Plot (Filled)

traja.plot_contour(df, filled=False, quiver=False, bins=32)
contour plot filled

Stream Plot

traja.plotting.plot_stream(trj: traja.frame.TrajaDataFrame, bins: Union[int, tuple, None] = None, cmap: str = 'viridis', contourfplot_kws: dict = {}, contourplot_kws: dict = {}, streamplot_kws: dict = {}, **kwargs) → matplotlib.figure.Figure[source]

Plot average flow from each grid cell to neighbor.

Parameters:
  • bins (int or tuple) – Tuple of x,y bin counts; if bins is int, bin count of x, with y inferred from aspect ratio
  • contourplot_kws – Additional keyword arguments for contour()
  • contourfplot_kws – Additional keyword arguments for contourf()
  • streamplot_kws – Additional keyword arguments for streamplot()
Returns:

Axes of stream plot

Return type:

ax (Axes)

traja.plot_contour(df, bins=32, contourfplot_kws={'cmap':'coolwarm'})
streamplot