cutPlot: Divides a plot in subplots

View source: R/cutPlot.R

cutPlotR Documentation

Divides a plot in subplots

Description

This function divides a plot in subplots (with dimX and dimY) and gives the coordinates of the grid in return. This function uses a procrustes analysis to fit the rectangle you gave to the plot you have.

Usage

cutPlot(projCoord, plot, corner, gridsize = 100, dimX = 200, dimY = 200)

Arguments

projCoord

A data frame with the projected coordinates with X and Y on the first and second column respectively

plot

Vector with the code of the plot

corner

Vector with the corner numbered from 1 to 4 for each plot, the numbered must be counted clockwise (see the result of the numberCorner())

gridsize

The size of the grid

dimX

A vector of the real size for the X axis for the plot (can be given one value it will be replicate for each plot)

dimY

A vector of the real size for the Y axis for the plot (can be given one value it will be replicate for each plot)

Value

This function return a data frame with :

  • plot: The code of the plot you use

  • subplot: The code of the subplot automatically generated

  • XRel: The relative coordinate for the axis X (following the corner 1->2) for the plot

  • YRel: The relative coordinate for the axis Y (following the corner 1->4) for the plot

  • XAbs: The absolute coordinate (projected) for the axis X (following the corner 1->2)

  • YAbs: The absolute coordinate (projected) for the axis Y (following the corner 1->4)

Author(s)

Arthur PERE

Examples


coord <- data.frame(X = c(0, 200, 0, 200), Y = c(0, 0, 200, 200)) + 5000
corner <- c(1, 2, 4, 3)
plot <- rep("plot1", 4)

cut <- cutPlot(coord, plot, corner, gridsize = 100, dimX = 200, dimY = 200)

# plot the result
plot(coord, main = "example", xlim = c(4900, 5300), ylim = c(4900, 5300), asp = 1)
text(coord, labels = corner, pos = 1)
points(cut$XAbs, cut$YAbs, pch = "+")
legend("bottomright", legend = c("orignal", "cut"), pch = c("o", "+"))

BIOMASS documentation built on Sept. 29, 2023, 5:09 p.m.