scatterPlot: generates a ggplot object of a scatterplot

View source: R/generalStat.R

scatterPlotR Documentation

generates a ggplot object of a scatterplot

Description

generates a ggplot object of a scatterplot

Usage

scatterPlot(
  data,
  xColumn = 1,
  yColumn = 2,
  xTransform = NA,
  yTransform = NA,
  removeNA = FALSE,
  xLabel = ifelse(is.character(xColumn), xColumn, colnames(data)[xColumn]),
  yLabel = ifelse(is.character(yColumn), yColumn, colnames(data)[yColumn]),
  pointAlpha = 0.75,
  pointColor = "black",
  pointFill = "red",
  pointShape = 21,
  pointSize = 2,
  smoothLine = FALSE,
  smoothLineType = "solid",
  smoothLineColor = "black",
  smoothAlpha = 0.1,
  smoothFill = "lightblue",
  smoothWidth = 0.5,
  smoothOrientation = "x",
  smoothConfidence = FALSE,
  smoothMethod = NULL,
  smoothFormula = NULL,
  title = paste(c(yLabel, " vs ", xLabel), collapse = ""),
  vertical = FALSE,
  xAxis = TRUE,
  xDefault = TRUE,
  xLimits = c(0, NA),
  xLog = FALSE,
  xSymmetric = FALSE,
  xSymmetricExpand = 0.05,
  xCentered = TRUE,
  xMedian = FALSE,
  xDeviations = 4,
  yAxis = TRUE,
  yDefault = TRUE,
  yLimits = c(0, NA),
  yLog = FALSE,
  ySymmetric = FALSE,
  ySymmetricExpand = 0.05,
  yCentered = TRUE,
  yMedian = FALSE,
  yDeviations = 4,
  gridLines = TRUE,
  gridLinesX = TRUE,
  gridLinesY = TRUE,
  abLine = NULL,
  ...
)

Arguments

data

the data tp be plotted, data.frame or similar

xColumn

specifies which column in the data argument contains the x-data (refer to column via number or character vector (column name))

yColumn

specifies which column in the data argument contains the y-data (refer to column via number or character vector (column name))

xTransform

specifies the function with which to transform the x-data (if needed), use transformData() for this

yTransform

specifies the function with which to transform the y-data (if needed), use transformData() for this

removeNA

if TRUE, the NA 'values' in the vector will be removed prior to plotting. @note this has consquence that ROWS will be removed when using multiple columns with data.frame's

xLabel

defines x-axis label

yLabel

defines y-axis label

pointAlpha

alpha ('see through' value) of the data points

pointColor

defines the color of the border of the data points

pointFill

defines the color of the data points themselves

pointShape

shape of the data points

pointSize

size of the data points

smoothLine

if TRUE then a smoothing line is drawn (via geom_smooth())

smoothLineType

type of the smoothing line

smoothLineColor

color of the smoothing line

smoothAlpha

alpha ('see through' value) of the smoothing line

smoothFill

specifies fill color pf tje smoothing confidence 'band'

smoothWidth

width of the smoothing nline

smoothOrientation

eihter "x" or "y", specifies what the smoothing orientation should be. See ?ggplot2::geom_smooth for more information

smoothConfidence

if TRUE then confidence 'band' is drawn around the smoothing line

smoothMethod

defines smoothin method. See ?ggplot2::geom_smooth for more info

smoothFormula

formula to use in smoothing function, See ?ggplot2::stat_smooth for more info

title

specifies the title

vertical

if TRUE then the plot is rotated 90 degrees (swap of X & Y)

xAxis

if TRUE, the x-axis is properly draw with label, ticks etc

xDefault

if default is set to FALSE, then together with xLimits, this can be used to define the exact range of the x-axis

xLimits

default = c(0,NA), together with xDefault, this can be used to define the exact range of the x-axis

xLog

if TRUE then logarithmic scale is used for the x-axis

xSymmetric

if TRUE then the range of x-axis will be adjusted to be equal on both the left and the right side of the center

xSymmetricExpand

allows for padding around data (x-axis), 0.05 means 5 percent extra wide x-axis range

xCentered

if TRUE, the plot will be 'cemtered' around the either the mean or median x-value

xMedian

if TRUE then median and mean absolute deviation (mad) are used for centering the plot along the x-axis; if FALSE then the mean and the standard deviation are used

xDeviations

defines how many deviations the range of the x-axis may differ from the mean or median. Range will be either (median-xDeviations*mad ,median+xDeviations**mad) or (mean - xDeviations*sd,mean + xDeviations*sd)

yAxis

if TRUE, the y-axis is properly draw with label, ticks etc

yDefault

if default is set to FALSE, then together with yLimits, this can be used to define the exact range of the y-axis

yLimits

default = c(0,NA), together with yDefault, this can be used to define the exact range of the y-axis

yLog

if TRUE then logarithmic scale is used for the y-axis

ySymmetric

if TRUE then the range of y-axis will be adjusted to be equal on both the left and the right side of the center

ySymmetricExpand

allows for padding around data (y-axis), 0.05 means 5 percent extra wide y-axis range

yCentered

if TRUE, the plot will be 'cemtered' around the either the mean or median y-value

yMedian

if TRUE then median and mean absolute deviation (mad) are used for centering the plot along the y-axis; if FALSE then the mean and the standard deviation are used

yDeviations

defines how many deviations the range of the x-axis may differ from the mean or median. Range will be either (median-xDeviations*mad ,median+xDeviations**mad) or (mean - xDeviations*sd,mean + xDeviations*sd)

gridLines

if TRUE then gridlines are shown

gridLinesX

if TRUE then vertical gridlines are shown (set gridLines to FALSE when using this)

gridLinesY

if TRUE then horizontal gridlines are shown (set gridLines to FALSE when using this)

abLine

for adding an geom_abline(), geom_hline or geom_vline function, see ggplot2::geom_abline

...

can be used to pass on other arguments to graphAdjust()

Value

a ggplot object


BenBruyneel/BBPersonalR documentation built on Aug. 23, 2024, 8:28 p.m.