kstreet13 / mazing

Utilities for making and plotting mazes
Other
4 stars 1 forks source link

`as.data.frame.maze()` to help plot with {ggplot2} #4

Open trevorld opened 4 months ago

trevorld commented 4 months ago
x <- maze(12L, 12L)
dfw <- as.data.frame(x, walls = TRUE)
dfs <- as.data.frame(x, start = "top", end = "bottom")
if (require("ggplot2", quietly = TRUE)) {
   ggplot(dfw, aes(x, y)) + geom_tile() + coord_equal() + theme_void() + 
   geom_path(aes(x=x, y=y), colour = "red", linewidth = 2, data = dfs)
}

image

trevorld commented 4 months ago

Not finished yet since I still plan to add support for method = "geom_segment" but currently provides a working proof of concept.

trevorld commented 4 months ago