summaryrefslogtreecommitdiff
path: root/images/l21m2.R
blob: 8998a49a0786e34509aa4140cdd1fcb8b09f201c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)