plot.maze {mazing} | R Documentation |
Plot a maze object
Description
Plot a maze object
Usage
## S3 method for class 'maze'
plot(x, walls = FALSE, ...)
## S3 method for class 'maze'
lines(
x,
walls = FALSE,
adjust = c(0, 0),
openings = NULL,
openings_direction = NULL,
...
)
Arguments
x |
A |
walls |
logical value, indicating that the walls of the maze should be
plotted, rather than the paths through the maze. Default is |
... |
Additional arguments passed to |
adjust |
A vector by which to adjust the overall position of the maze.
Should be a numeric vector of length 2, indicating the |
openings |
Locations in the maze where a certain wall(s) should not be
drawn (only applies when |
openings_direction |
Character vector describing which walls should not
be drawn at the locations specified by |
Details
When plotting, the coordinates for locations in the maze are taken from the indices of the corresponding locations in the matrix representation. This means that the plot will appear to be flipped vertically relative to the matrix representation of the maze.
The openings_direction
argument specifies where to create an
opening (ie. where not to draw walls), relative to a location in the maze
given by openings
. Possible values are: "left"
,
"right"
, "top"
, "bottom"
, "topleft"
,
"topright"
, "bottomright"
, "bottomleft"
, and
"all"
. If not specified, this will be set as the first value in
c("left","right","top","bottom")
to reference a wall that would
otherwise have been drawn.
Value
Returns NULL
, invisibly.
Examples
m <- maze(10,10)
plot(m, walls = TRUE)
lines(m, lwd = 5, col = 3)