How to use the movingpandas.trajectory_plotter._TrajectoryPlotter function in movingpandas

To help you get started, we’ve selected a few movingpandas examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github anitagraser / movingpandas / movingpandas / trajectory.py View on Github external
args :
            These parameters will be passed to the TrajectoryPlotter
        kwargs :
            These parameters will be passed to the TrajectoryPlotter

        Returns
        -------
        Holoviews plot

        Examples
        --------
        Plot speed along trajectory (with legend and specified figure size):

        >>> trajectory.hvplot(c='speed', line_width=7.0, width=700, height=400, colorbar=True)
        """
        return _TrajectoryPlotter(self, *args, **kwargs).hvplot()
github anitagraser / movingpandas / movingpandas / trajectory.py View on Github external
args :
            These parameters will be passed to the TrajectoryPlotter
        kwargs :
            These parameters will be passed to the TrajectoryPlotter

        Returns
        -------
        Matplotlib plot

        Examples
        --------
        Plot speed along trajectory (with legend and specified figure size):

        >>> trajectory.plot(column='speed', legend=True, figsize=(9,5))
        """
        return _TrajectoryPlotter(self, *args, **kwargs).plot()
github anitagraser / movingpandas / movingpandas / trajectory_plotter.py View on Github external
return line_gdf.hvplot(geo=self.hvplot_is_geo, tiles=self.hvplot_tiles, *self.args, **self.kwargs)

    def plot(self):
        if not self.ax:
            self.ax = plt.figure(figsize=self.figsize).add_subplot(1, 1, 1)
        ax = self._plot_trajectory(self.data)
        self.kwargs['legend'] = False  # has to be removed after the first iteration, otherwise we get multiple legends!
        self.kwargs.pop('column', None)  # has to be popped, otherwise there's an error in the following plot call if we don't remove column from kwargs
        return ax

    def hvplot(self):
        opts.defaults(opts.Overlay(width=self.width, height=self.height, active_tools=['wheel_zoom']))
        return self._hvplot_trajectory(self.data)


class _TrajectoryCollectionPlotter(_TrajectoryPlotter):
    def __init__(self, data, *args, **kwargs):
        super().__init__(data, *args, **kwargs)

    def plot(self):
        if self.column:
            speed_col_name = self.data.trajectories[0].get_speed_column_name()
            if self.column == speed_col_name and speed_col_name not in self.data.trajectories[0].df.columns:
                self.data.add_speed(overwrite=True)
            self.max_value = self.kwargs.pop('vmax', self.data.get_max(self.column))
            self.min_value = self.kwargs.pop('vmin', self.data.get_min(self.column))

        self.ax = plt.figure(figsize=self.figsize).add_subplot(1, 1, 1)
        for traj in self.data.trajectories:
            self.ax = self._plot_trajectory(traj)
            self.kwargs['legend'] = False  # has to be removed after the first iteration, otherwise we get multiple legends!