summaryrefslogtreecommitdiff
path: root/images/l21m2.R
diff options
context:
space:
mode:
Diffstat (limited to 'images/l21m2.R')
-rwxr-xr-ximages/l21m2.R20
1 files changed, 20 insertions, 0 deletions
diff --git a/images/l21m2.R b/images/l21m2.R
new file mode 100755
index 0000000..8998a49
--- /dev/null
+++ b/images/l21m2.R
@@ -0,0 +1,20 @@
+#!/usr/bin/env Rscript
+`%>%` <- magrittr::`%>%`
+xpoints <- seq (-1, 1, length.out = 100)
+ypoints <- seq (-1, 1, length.out = 100)
+compute_l1 <- function (x, y) abs (x) + abs (y)
+compute_l2 <- function (x, y) sqrt (x ^ 2 + y ^ 2)
+data <- (tibble::tibble (expand.grid (x = xpoints, y = ypoints))
+ %>% dplyr::mutate (`$\\left\\|W\\right\\|_{2, 1}$` = compute_l1 (x, y),
+ `$\\left\\|W\\right\\|_F$` = compute_l2 (x, y))
+ %>% dplyr::mutate (`$\\left\\|W\\right\\|_{2, 1 - 2}$` =
+ `$\\left\\|W\\right\\|_{2, 1}$`
+ - `$\\left\\|W\\right\\|_F$`))
+
+plotl21 <- (ggplot2::ggplot (data, ggplot2::aes (x = x, y = y, fill = `$\\left\\|W\\right\\|_{2, 1}$`))
+ + ggplot2::geom_raster ())
+plotl21m2 <- (ggplot2::ggplot (data, ggplot2::aes (x = x, y = y, fill = `$\\left\\|W\\right\\|_{2, 1 - 2}$`))
+ + ggplot2::geom_raster ())
+plot <- gridExtra::arrangeGrob (plotl21, plotl21m2, nrow = 2)
+filename <- Sys.getenv ("OUTPUT")
+ggplot2::ggsave (filename, plot, device = "svg", width = 5.5, height = 6.5)