addLine | R Documentation |
Add a line layer to a ggplot
object.
addLine(
data = NULL,
metaData = NULL,
x = NULL,
y = NULL,
caption = NULL,
color = NULL,
shape = NULL,
size = NULL,
linetype = NULL,
dataMapping = NULL,
plotConfiguration = NULL,
plotObject = NULL
)
data |
A data.frame to use for plot. |
metaData |
A named list of information about |
x |
Numeric values to plot along the |
y |
Numeric values to plot along the |
caption |
Optional character values defining the legend captions of the plot. |
color |
Optional character values defining the colors of the plot layer.
See |
shape |
Optional character values defining the shapes/symbols of the plot layer.
See enum |
size |
Optional numeric values defining the size of the plot layer. |
linetype |
Optional character values defining the linetype of the plot layer.
See enum |
dataMapping |
A |
plotConfiguration |
An optional |
plotObject |
An optional |
A ggplot
object
For examples, see: https://www.open-systems-pharmacology.org/TLF-Library/articles/atom-plots.html
Other atom plots:
addErrorbar()
,
addRibbon()
,
addScatter()
,
initializePlot()
# Add line using x and y
addLine(x = c(1, 2, 1, 2, 3), y = c(5, 0, 2, 3, 4))
# Add line using a data.frame
time <- seq(0, 30, 0.1)
lineData <- data.frame(x = time, y = cos(time))
addLine(
data = lineData,
dataMapping = XYGDataMapping$new(x = "x", y = "y")
)
# Or for simple cases a smart mapping will get directly x and y from data
addLine(data = lineData)
# Add a line with caption
addLine(data = lineData, caption = "My line plot")
# Add a line with specific properties
addLine(
data = lineData,
color = "blue", linetype = "longdash", size = 0.5, caption = "My data"
)
# Add a line with specific properties
p <- addLine(
data = lineData,
color = "blue", linetype = "longdash", size = 0.5, caption = "My data"
)
addLine(
x = c(0, 1), y = c(1, 0),
color = "red", linetype = "solid", size = 1,
plotObject = p
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.