scaling.plot: Scaling plots in the ggplot style

View source: R/scaling.plot.R View source: R/gg.scaling.plot.R

scaling.plotR Documentation

Scaling plots in the ggplot style

Description

Make pretty plots of the relationship between two variables, tailored for use in examining allometric scaling relationships.

Make pretty plots of the relationship between two variables, tailored for use in examining allometric scaling relationships.

Usage

scaling.plot(
  x,
  y,
  group = NULL,
  group.title = NULL,
  title = NULL,
  xlab = NULL,
  ylab = NULL,
  convex.hulls = TRUE,
  viridis.color.option = "viridis",
  color = NULL,
  pt.size = 1.5,
  pt.alpha = 0.85,
  hull.alpha = 0.2,
  save.as = NULL,
  height = 5,
  width = 7,
  fixed.aspect = TRUE,
  label.groups = TRUE,
  groups.trendlines = FALSE,
  include.legend = FALSE,
  isometry.line = FALSE,
  isometry.line.color = "gray35",
  verbose = TRUE,
  ...
)

scaling.plot(
  x,
  y,
  group = NULL,
  group.title = NULL,
  title = NULL,
  xlab = NULL,
  ylab = NULL,
  convex.hulls = TRUE,
  viridis.color.option = "viridis",
  color = NULL,
  pt.size = 1.5,
  pt.alpha = 0.85,
  hull.alpha = 0.2,
  save.as = NULL,
  height = 5,
  width = 7,
  fixed.aspect = TRUE,
  label.groups = TRUE,
  groups.trendlines = FALSE,
  include.legend = FALSE,
  isometry.line = FALSE,
  isometry.line.color = "gray35",
  verbose = TRUE,
  ...
)

Arguments

x

A vector of numerical values to plot on the horizontal axis.

y

A vector of numerical values to plot on the vertical axis.

group

A factor to group samples.

group.title

An optional title for the group legend.

convex.hulls

A logical factor specifying whether to plot convex hulls around groups.

viridis.color.option

The color palette to use from the viridis package.

color

The color of points and hulls in each group.

pt.size

The size of individual points.

pt.alpha

The opacity of individual points.

hull.alpha

The opacity of the convex hulls.

save.as

An optional file name to export the plot.

height

The height of the exported plot.

width

The width of the exported plot.

fixed.aspect

A logical factor specifying whether to enforce an equal aspect ratio.

label.groups

A logical factor specifying whether to label groups.

groups.trendlines

A logical factor specifying whether to include trend lines for each group.

include.legend

A logical factor specifying whether to include a legend.

isometry.line

A logical factor specifying whether to include a slope illustrating slope of 1.

isometry.line.color

The color of isometry line.

verbose

A logical factor specifying whether to output a table of slopes.

Source

Dave Angelini david.r.angelini@gmail.com [aut, cre]

Dave Angelini david.r.angelini@gmail.com [aut, cre]

Examples

data(plethodon, package = "geomorph")

pletho.links <- matrix(c(4,5,5,6,6,7,7,8,8,9,9,10,10,11,2,4,12,2,3,5),
                       ncol = 2, byrow = TRUE)
landmark.plot(plethodon$land[,,1], links = pletho.links )

distance <- function(x1,y1,x2,y2) { d <- sqrt((x1-x2)^2+(y1-y2)^2); return(d) }

head.length <- apply(plethodon$land, 3, function(xy) {
  distance(xy[7,1],xy[7,2], xy[12,1],xy[12,2])
} )
jaw.length <- apply(plethodon$land, 3, function(xy) {
  distance(xy[3,1],xy[3,2], xy[5,1],xy[5,2])
} )

scaling.plot(
  x = log10(head.length), y = log10(jaw.length),
  group=plethodon$species, group.title = "species",
  xlab = "head length (log10 mm)", ylab = "jaw length (log10 mm)",
  include.legend = TRUE,
  isometry.line = TRUE
)

data(plethodon, package = "geomorph")

pletho.links <- matrix(c(4,5,5,6,6,7,7,8,8,9,9,10,10,11,2,4,12,2,3,5),
                       ncol = 2, byrow = TRUE)
landmark.plot(plethodon$land[,,1], links = pletho.links )

distance <- function(x1,y1,x2,y2) { d <- sqrt((x1-x2)^2+(y1-y2)^2); return(d) }

head.length <- apply(plethodon$land, 3, function(xy) {
  distance(xy[7,1],xy[7,2], xy[12,1],xy[12,2])
} )
jaw.length <- apply(plethodon$land, 3, function(xy) {
  distance(xy[3,1],xy[3,2], xy[5,1],xy[5,2])
} )

scaling.plot(
  x = log10(head.length), y = log10(jaw.length),
  group=plethodon$species, group.title = "species",
  xlab = "head length (log10 mm)", ylab = "jaw length (log10 mm)",
  include.legend = TRUE,
  isometry.line = TRUE
)


aphanotus/borealis documentation built on Nov. 4, 2022, 8:44 p.m.