Title: | Plot Columns of Two Matrices Against Each Other Using 'ggplot2' |
---|---|
Description: | A quick and easy way of plotting the columns of two matrices or data frames against each other using 'ggplot2'. Although 'ggmatplot' doesn't provide the same flexibility as 'ggplot2', it can be used as a workaround for having to wrangle wide format data into long format for plotting with 'ggplot2'. |
Authors: | Xuan Liang [aut, cre] |
Maintainer: | Xuan Liang <[email protected]> |
License: | GPL-3 |
Version: | 0.1.3 |
Built: | 2025-02-16 02:45:30 UTC |
Source: | https://github.com/xuan-liang/ggmatplot |
ggmatplot
is a quick and easy way of plotting the columns of two matrices
or data frames against each other using
ggplot2
.
ggmatplot( x = NULL, y = NULL, plot_type = c("point", "line", "both", "density", "histogram", "boxplot", "dotplot", "errorplot", "violin", "ecdf"), color = NULL, fill = NULL, shape = NULL, linetype = NULL, xlim = c(NA, NA), ylim = c(NA, NA), log = NULL, main = NULL, xlab = NULL, ylab = NULL, legend_label = NULL, legend_title = NULL, desc_stat = "mean_se", asp = NA, ... )
ggmatplot( x = NULL, y = NULL, plot_type = c("point", "line", "both", "density", "histogram", "boxplot", "dotplot", "errorplot", "violin", "ecdf"), color = NULL, fill = NULL, shape = NULL, linetype = NULL, xlim = c(NA, NA), ylim = c(NA, NA), log = NULL, main = NULL, xlab = NULL, ylab = NULL, legend_label = NULL, legend_title = NULL, desc_stat = "mean_se", asp = NA, ... )
x , y
|
Vectors or matrices of data.
|
plot_type |
A string specifying the type of plot. Possible plot types
are |
color , fill
|
Vectors of colors. Defining only one of them will update
both
|
shape , linetype
|
A vector of shapes or line types respectively.
|
xlim , ylim
|
Ranges of x and y axes.
|
log |
A string defining which axes to transform into a log scale.
( |
main , xlab , ylab , legend_title
|
Strings to update plot title, x axis label, y axis label and legend title respectively. |
legend_label |
A vector of strings, to rename the legend labels. |
desc_stat |
Descriptive statistics to be used for visualizing errors,
in |
asp |
The y/x aspect ratio. |
... |
Other arguments passed on to the plot. Possible arguments are those that can be passed on to the underlying ggplot layers. |
A ggplot object. The columns of the input matrices will be plotted against each other using the defined plot type.
ggmatplot
plots are built upon ggplot2 layers
. The following is a list of
ggmatplot
plot types, along with their underlying
ggplot geoms
or stats
.
point geom_point
line geom_line
both geom_point
+
geom_line
density geom_density
histogram geom_histogram
boxplot geom_boxplot
dotplot geom_dotplot
errorplot geom_pointrange
violin geom_violin
ecdf stat_ecdf
# Define a data set iris_sub <- subset(iris, Species == "setosa") ggmatplot(iris_sub[, c(1, 3)], iris_sub[, c(2, 4)]) # Modify legend label and axis ggmatplot(iris_sub[, c(1, 3)], iris_sub[, c(2, 4)], shape = c(4, 6), legend_label = c("Sepal", "Petal"), legend_title = "", xlab = "Length", ylab = "Width" )
# Define a data set iris_sub <- subset(iris, Species == "setosa") ggmatplot(iris_sub[, c(1, 3)], iris_sub[, c(2, 4)]) # Modify legend label and axis ggmatplot(iris_sub[, c(1, 3)], iris_sub[, c(2, 4)], shape = c(4, 6), legend_label = c("Sepal", "Petal"), legend_title = "", xlab = "Length", ylab = "Width" )