Created
October 2, 2019 13:59
-
-
Save fkeck/4820db83b9ff2fbf1f7fe901563ddc82 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| col_bar_v <- function(col, data.min, data.max){ | |
| plot(c(0, 10), c(data.min, data.max), type = "n", bty = "n", xaxt = "n", yaxt = "n", xlab = "", ylab = "") | |
| tk <- pretty(c(data.min, data.max), 7) | |
| tk <- tk[c(-which(tk < data.min), -which(tk > data.max))] | |
| axis(2, las = 1, at = tk, col = NA, col.ticks = 1) | |
| inc <- (data.max - data.min)/ length(col) | |
| for(i in seq(1, length(col))){ | |
| rect(0, data.min + inc * (i- 1), 10, data.min + inc * i, col = col[i], border = NA) | |
| } | |
| } | |
| col_bar_h <- function(col, data.min, data.max, n.tick = 5){ | |
| plot(c(data.min, data.max), c(0, 10), type = "n", bty = "n", xaxt = "n", yaxt = "n", xlab = "", ylab = "") | |
| tk <- pretty(c(data.min, data.max), n.tick + 2) | |
| tk <- tk[c(-which(tk < data.min), -which(tk > data.max))] | |
| axis(1, at = tk, col = NA, col.ticks = 1) | |
| inc <- (data.max - data.min)/ length(col) | |
| for(i in seq(1, length(col))){ | |
| rect(data.min + inc * (i- 1), 0, data.min + inc * i, 10, col = col[i], border = NA) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment