Movatterモバイル変換


[0]ホーム

URL:


Title:Plot Columns of Two Matrices Against Each Other Using 'ggplot2'
Version:0.1.2
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'.
URL:https://github.com/xuan-liang/ggmatplot,https://xuan-liang.github.io/ggmatplot/
BugReports:https://github.com/xuan-liang/ggmatplot/issues
License:GPL-3
Encoding:UTF-8
RoxygenNote:7.1.2
Depends:R (≥ 3.4.0), ggplot2
Imports:stats
Suggests:rmarkdown, knitr, testthat (≥ 3.0.0), vdiffr, tibble, tidyr,dplyr, covr
VignetteBuilder:knitr
Config/testthat/edition:3
NeedsCompilation:no
Packaged:2022-05-17 01:27:13 UTC; taozou
Author:Xuan LiangORCID iD [aut, cre], Francis K. C. HuiORCID iD [aut], Emi TanakaORCID iD [aut], Dilinie SeimonORCID iD [aut]
Maintainer:Xuan Liang <xuan.liang@anu.edu.au>
Repository:CRAN
Date/Publication:2022-05-17 02:20:02 UTC

ggmatplot

Description

ggmatplot is a quick and easy way of plotting the columns of two matricesor data frames against each other usingggplot2.

Usage

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,  ...)

Arguments

x,y

Vectors or matrices of data.

  • The number of rows ofx andy should be the same.

  • Eitherx ory should be a vector, unless the number of columns ofxandy are the same.

  • Missing values (NAs) are allowed.

  • If eitherx ory is missing, the other is used asy and a vector of1:n is used asx.

plot_type

A string specifying the type of plot. Possible plot typesarepoint,line,both(point + line),density,histogram,boxplot,dotplot,errorplot,violin, andecdf. Default plot_type ispoint.

color,fill

Vectors of colors. Defining only one of them will updatebothcolor andfill aesthetics of the plot by default, unless they areboth defined simultaneously.

  • The number of colors should match the higher number of columns ofmatricesx ory, and will correspond to each of those columns.

  • If only a single color is given, the same color will be used for allcolumns.

shape,linetype

A vector of shapes or line types respectively.

  • The number of shapes/line types should match the higher number of columnsof matricesx ory, and will correspond to each of those columns.

  • If only a single shape/line type is given, the same shape/line type willbe used for all columns.

xlim,ylim

Ranges of x and y axes.

  • Each of them should be a two element vector specifying the lower and upperlimits of the scale.

  • If the larger value is given first, the scale will be reversed. If one ofthe limits is given asNA, the corresponding limit from the range of datawill be used.

log

A string defining which axes to transform into a log scale.(x,y orxy)

main,xlab,ylab,legend_title

Strings to update plot title, x axislabel, 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,inerrorplot. Possible values aremean_se,mean_sd,mean_range,median_iqr andmedian_range. Default desc_stat ismean_se.

asp

The y/x aspect ratio.

...

Other arguments passed on to the plot. Possible arguments arethose that can be passed on to theunderlying ggplot layers.

Value

A ggplot object. The columns of the input matrices will be plottedagainst each other using the defined plot type.

Plot Types

ggmatplotplots are built upon⁠ggplot2 layers⁠. The following is a list ofggmatplot plot types, along with their underlying⁠ggplot geoms⁠orstats.

Examples

# Define a data setiris_sub <- subset(iris, Species == "setosa")ggmatplot(iris_sub[, c(1, 3)], iris_sub[, c(2, 4)])# Modify legend label and axisggmatplot(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")

[8]ページ先頭

©2009-2025 Movatter.jp