diff --git a/docs/rst/modules/plotting.rst b/docs/rst/modules/plotting.rst index 2b6bc90..e5cf27f 100644 --- a/docs/rst/modules/plotting.rst +++ b/docs/rst/modules/plotting.rst @@ -30,7 +30,8 @@ Parameters ---------- - ``terrain: Terrain``: The terrain to plot -- ``paths: List[Path] = []``: The paths to plot +- ``path: Path = None``: The path to plot +- ``paths: List[Path] = []``: The paths to plot (if ``path`` is not used) - ``paths_legends: List[str] = None``: The legend message for each path - ``add_cost_to_legend: bool = False``: If True, the cost of the path will be added as legend - ``colors: List[str] = ['r', 'y', 'm', 'k', 'c', 'g', 'b']``: The colors to use for each paths @@ -78,8 +79,9 @@ Parameters ---------- - ``terrain: Terrain``: The terrain to plot +- ``path: Path = None``: The path to plot +- ``paths: List[Path] = []``: The paths to plot (if ``path`` is not used) - ``angles: List[tuple] = [(45, 45), (45, 225)]``: The angles from where to plot the terrain -- ``paths: List[Path] = []``: The paths to plot - ``colors: List[str] = ['r', 'y', 'm', 'k', 'c', 'g', 'b']``: The colors to use for each paths - ``cmap: str = 'terrain'``: The ``colormap`` to use for the terrain - ``title: str = 'Terrain'``: The title of the plot diff --git a/src/sIArena/terrain/plot/plot_2D.py b/src/sIArena/terrain/plot/plot_2D.py index 138e312..1dc314d 100644 --- a/src/sIArena/terrain/plot/plot_2D.py +++ b/src/sIArena/terrain/plot/plot_2D.py @@ -6,6 +6,7 @@ def plot_terrain_2D( terrain: Terrain, + path: Path = None, paths: List[Path] = [], paths_legends: List[str] = None, add_cost_to_legend: bool = False, @@ -15,6 +16,9 @@ def plot_terrain_2D( ): """Plots the terrain and the given paths""" + if path is not None: + paths = [path] + plt.clf() plt.imshow(terrain.matrix, cmap=cmap) diff --git a/src/sIArena/terrain/plot/plot_3D.py b/src/sIArena/terrain/plot/plot_3D.py index d8df9fe..18a0529 100644 --- a/src/sIArena/terrain/plot/plot_3D.py +++ b/src/sIArena/terrain/plot/plot_3D.py @@ -8,14 +8,18 @@ def plot_terrain_3D( terrain: Terrain, - angles: List[tuple] = [(45, 45), (45, 225)], + path: Path = None, paths: List[Path] = [], + angles: List[tuple] = [(45, 45), (45, 225)], colors: List[str] = ['r', 'y', 'm', 'k', 'c', 'g', 'b'], cmap: str = 'terrain', title: str = 'Terrain', ): """Plots the terrain and the given paths""" + if path is not None: + paths = [path] + fig = plt.figure(figsize=(18, 6)) np_matrix = np.array(terrain.matrix)