Plot Walker Paths
plot_walker_paths.RdVisualizes the paths taken by all walkers during the simulation, showing their starting positions, trajectories, and termination points.
Usage
plot_walker_paths(
result,
main = "Walker Paths and Final Positions",
colors = NULL,
add_grid = TRUE,
grid_col = "lightgray",
lwd = 1.5,
cex_start = 1.5,
cex_end = 2,
legend = TRUE,
legend_pos = "topright"
)Arguments
- result
A simulation result object returned by
run_simulation- main
Character string for the plot title. Default is "Walker Paths and Final Positions"
- colors
Optional vector of colors for walker paths. If NULL (default), uses rainbow colors
- add_grid
Logical indicating whether to add grid lines. Default is TRUE
- grid_col
Color for grid lines. Default is "lightgray"
- lwd
Line width for paths. Default is 1.5
- cex_start
Size of starting position markers. Default is 1.5
- cex_end
Size of ending position markers. Default is 2
- legend
Logical indicating whether to add a legend. Default is TRUE
- legend_pos
Position of legend. Default is "topright"
Details
Walker paths are shown in different colors. Starting positions are marked with circles (pch 19). Ending positions use different markers:
Square (pch 15): Terminated due to black pixel (black_neighbor or touched_black)
Triangle (pch 17): Terminated at boundary (hit_boundary)
X (pch 4): Terminated at max steps (max_steps)
Examples
if (FALSE) { # \dontrun{
result <- run_simulation(grid_size = 20, n_walkers = 8)
plot_walker_paths(result)
} # }