Skip to content

Commit

Permalink
Add path arg to plotting
Browse files Browse the repository at this point in the history
Signed-off-by: jparisu <[email protected]>
  • Loading branch information
jparisu committed Feb 25, 2024
1 parent dd916f1 commit 54f8cf1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 4 additions & 2 deletions docs/rst/modules/plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/sIArena/terrain/plot/plot_2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)

Expand Down
6 changes: 5 additions & 1 deletion src/sIArena/terrain/plot/plot_3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 54f8cf1

Please sign in to comment.