| plot_matrix | R Documentation |
Creates a "balloon plot" to visualize numeric data in a matrix or contingency table.
plot_matrix(
x,
title = "Balloon plot",
shape.color = c("tomato"),
s.min = 1,
s.max = 30,
x.axis = NULL,
y.axis = NULL,
x.lab = "",
y.lab = "",
bg.color = "white",
grid.color = "black",
grid.width = 0.1,
size.by = c("column", "row", "global", "none"),
color.by = c("column", "row", "global", "none"),
number.size = 6,
shape.by = c("column", "row", ""),
shapes = c(21, 22, 23, 24),
color.contrast = 1
)
x |
a numeric matrix or table to be plotted. |
title |
a character string for the main title of the plot.
Defaults to |
shape.color |
a character string specifying the
color for entries (e.g., |
s.min |
a numeric value specifying the minimum size
of the shapes. Defaults to |
s.max |
a numeric value specifying the maximum size
of the shapes. Defaults to |
x.axis |
a character vector for custom x-axis labels.
If |
y.axis |
a character vector for custom y-axis labels.
If |
x.lab |
a character string for the x-axis title.
Defaults to |
y.lab |
a character string for the y-axis title.
Defaults to |
bg.color |
a character string for the background
color of the tiles. Defaults to |
grid.color |
a character string specifying color of
grid lines ( |
grid.width |
a numeric value to specify the width of grid lines. |
size.by |
a character string to specify how to
scale the size of balloon: |
color.by |
a character string to specify how to
scale the color of balloon: |
number.size |
a numeric value specifying the font size for text. |
shape.by |
a character string to specify how to
choose the shape of balloon: |
shapes |
a numeric vector to specify shape codes. |
color.contrast |
a numeric value between 0 and 1 to adjust
the lightness of the lowest values. Defaults to |
Each entry in the matrix is represented by a shape, with size and color corresponding to the magnitude of value in the entry. It offers an alternative to heatmap for displaying count data.
A ggplot object.
library(ggplot2)
mat <- matrix(c(10, 20, 30, 50, 80, 60, 40, 30), nrow = 2)
rownames(mat) <- c("Row1", "Row2")
colnames(mat) <- c("C1", "C2", "C3", "C4")
# Color by Row (Row 1 = red, Row 2 = blue)
plot_matrix(mat, color.by = "row", shape.color = c("tomato", "steelblue"))
# Color by Column (Rainbow colors)
plot_matrix(mat, color.by = "column", shape.color = c("red", "green", "blue", "orange"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.