#' Create a matrix plot
#' @description This function is the equivalent of \code{\link[ggplot2]{ggplot}}
#' in ggplot2.
#' @param data list of matrix-like object or matrix_tbl.
#' @param ... other params passing to \code{\link[ggmatrix]{matrixs_to_df}}.
#' @return an object of class gg onto which layers, scales, etc. can be added.
#' @importFrom ggplot2 ggplot aes_string
#' @examples
#' ggmat(list(mtcars = mtcars))
#' m1 <- matrix(rnorm(100), nrow = 20)
#' m2 <- matrix(rnorm(100), nrow = 20)
#' ggmat(list(m1 = m1, m2 = m2)) + geom_triangle(aes(fill = m1))
#' ggmat(list(m1 = m1, m2 = m2)) +
#' geom_triangle(aes(fill.upper = m1, fill.lower = m2)) +
#' scale_fill_upper_gradientn(colours = c("red", "white", "blue")) +
#' scale_fill_lower_gradientn(colours = c("#E9A3C9", "#F7F7F7", "#A1D76A"))
#' @seealso \code{\link[ggmatrix]{matrixs_to_df}}.
#' @export
ggmat <- function(data, ...) {
if(!inherits(data, "matrix_tbl"))
data <- matrixs_to_df(data, ...)
create_matrix_plot(data)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.