| Title: | Library for standardized graphs |
|---|---|
| Description: | This library provides a standardized approach to creating graphs and tables in the ospsuite context. It is based on ggplot2. |
| Authors: | Open-Systems-Pharmacology Community [cph], Katrin Coboeken [aut, cre] |
| Maintainer: | Katrin Coboeken <[email protected]> |
| License: | GPL-2 | file LICENSE |
| Version: | 1.2.0 |
| Built: | 2026-07-06 12:18:03 UTC |
| Source: | https://github.com/Open-Systems-Pharmacology/OSPSuite.Plots |
Add a layer for LLOQ lines to a ggplot object.
addLLOQLayer( plotObject, mappedData, layerToCall, useLinetypeAsAttribute, geomLLOQAttributes )addLLOQLayer( plotObject, mappedData, layerToCall, useLinetypeAsAttribute, geomLLOQAttributes )
plotObject |
A |
mappedData |
A |
layerToCall |
A function representing the ggplot2 geom layer. |
useLinetypeAsAttribute |
A boolean indicating whether to set the line type as an attribute (TRUE) or not (FALSE); if TRUE, no legend is created. |
geomLLOQAttributes |
Additional attributes for the LLOQ layer. |
The updated ggplot object.
This function adds a customizable watermark to a ggplot object. The watermark can be configured with various options such as position, angle, font size, color, and transparency.
addWatermark(plotObject)addWatermark(plotObject)
plotObject |
A ggplot object to which the watermark will be added. |
A ggplot object with a watermark drawn on it. The watermark is displayed according to the specified options.
Other watermark:
ggplotWithWatermark(),
plot.ggWatermark(),
print.ggWatermark()
## Not run: # Example usage (watermark enabled by default) p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() p_with_watermark <- addWatermark(p) print(p_with_watermark) # Example of customizing the watermark setOspsuite.plots.option(optionKey = OptionKeys$watermarkLabel, value = "Custom Watermark") watermarkFormat <- getOspsuite.plots.option(optionKey = OptionKeys$watermarkFormat) watermarkFormat$x <- 0.5 # Centered horizontally watermarkFormat$y <- 0.5 # Centered vertically watermarkFormat$angle <- 45 # Rotated 45 degrees watermarkFormat$fontsize <- 6 # Font size 6 watermarkFormat$color <- "blue" # Blue color watermarkFormat$alpha <- 0.5 # 50% transparency setOspsuite.plots.option(optionKey = OptionKeys$watermarkFormat, value = watermarkFormat) # Create plot with customized watermark p_custom <- addWatermark(p) print(p_custom) ## End(Not run)## Not run: # Example usage (watermark enabled by default) p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() p_with_watermark <- addWatermark(p) print(p_with_watermark) # Example of customizing the watermark setOspsuite.plots.option(optionKey = OptionKeys$watermarkLabel, value = "Custom Watermark") watermarkFormat <- getOspsuite.plots.option(optionKey = OptionKeys$watermarkFormat) watermarkFormat$x <- 0.5 # Centered horizontally watermarkFormat$y <- 0.5 # Centered vertically watermarkFormat$angle <- 45 # Rotated 45 degrees watermarkFormat$fontsize <- 6 # Font size 6 watermarkFormat$color <- "blue" # Blue color watermarkFormat$alpha <- 0.5 # 50% transparency setOspsuite.plots.option(optionKey = OptionKeys$watermarkFormat, value = watermarkFormat) # Create plot with customized watermark p_custom <- addWatermark(p) print(p_custom) ## End(Not run)
add X-scale
addXScale(plotObject, xScale, xScaleArgs = list())addXScale(plotObject, xScale, xScaleArgs = list())
plotObject |
A |
xScale |
The x-axis scale type. Available is 'linear', 'log', 'discrete' |
xScaleArgs |
A list of arguments for the x-axis scale. |
The updated ggplot object
Add X and Y scales to a ggplot object.
addXYScale( plotObject, xScale = NULL, xScaleArgs = list(), yScale = NULL, yScaleArgs = list(), secAxis = waiver() )addXYScale( plotObject, xScale = NULL, xScaleArgs = list(), yScale = NULL, yScaleArgs = list(), secAxis = waiver() )
plotObject |
A |
xScale |
The x-axis scale type. Available is 'linear', 'log', 'discrete' |
xScaleArgs |
A list of arguments for the x-axis scale. |
yScale |
The y-axis scale type. Available is 'linear', 'log' |
yScaleArgs |
A list of arguments for the y-axis scale. |
secAxis |
Secondary axis arguments for scale_y functions. |
The updated ggplot object.
add y-scale
addYScale(plotObject, yScale, yScaleArgs = list(), secAxis = waiver())addYScale(plotObject, yScale, yScaleArgs = list(), secAxis = waiver())
plotObject |
A |
yScale |
The y-axis scale type. Available is 'linear', 'log' |
yScaleArgs |
A list of arguments for the y-axis scale. |
secAxis |
Secondary axis arguments for scale_y functions. |
The updated ggplot object
enumeration keys for OSPSuite.plots scaling options for axis scalings
AxisScalesAxisScales
enumeration keys for mode of Binning
BINNINGMODEBINNINGMODE
List with some color maps for Theme object.
The ospDefault color map is based on colors in default_igv qualitative
color palette from {ggsci} package.
colorMapscolorMaps
Other setDefault functions:
getDefaultGeomAttributes(),
getDefaultOptions(),
getOspsuite.plots.option(),
resetDefaultColorMapDistinct(),
resetDefaultTheme(),
resetDefaults(),
setDefaultColorMapDistinct(),
setDefaultTheme(),
setDefaults(),
setOspsuite.plots.option()
This class represents a combined plot object that includes a plot and an optional table. It provides methods to get and set the plot and table objects, as well as to print the combined output.
plotObjectA ggplot object representing the main plot.
tableObjectA ggplot object representing the table.
relWidthsA numeric vector of length 2 specifying the relative widths of the plot and table.
CombinedPlot$new()CombinedPlot$new(plotObject = ggplot(), tableObject = NULL)
plotObjectA ggplot object for the main plot. Combine the combined plot and table
This method combines the plot and table into a single output and displays it.
tableObjectA ggplot object for the table.
CombinedPlot$combined()CombinedPlot$combined()
A ggplot object representing the combined plot and table Print the combined plot and table
This method overrides the default print function to display the combined output.
CombinedPlot$print()CombinedPlot$print()
Invisibly returns the combined ggplot object
CombinedPlot$clone()The objects of this class are cloneable with this method.
CombinedPlot$clone(deep = FALSE)
deepWhether to make a deep clone.
## Not run: # Create a new CombinedPlot instance combinedPlotInstance <- CombinedPlot$new(plotObject = myPlotObject, tableObject = myTableObject) # Print the combined plot and table print(combinedPlotInstance) # or simply combinedPlotInstance ## End(Not run)## Not run: # Create a new CombinedPlot instance combinedPlotInstance <- CombinedPlot$new(plotObject = myPlotObject, tableObject = myTableObject) # Print the combined plot and table print(combinedPlotInstance) # or simply combinedPlotInstance ## End(Not run)
This function constructs a label by appending a unit in square brackets if both the label and unit are provided. If the unit is empty or NULL, only the label is returned.
constructLabelWithUnit(label, unit)constructLabelWithUnit(label, unit)
label |
A character string representing the label. It should not be NULL. |
unit |
A character string representing the unit. It can be NULL or an empty string. |
A character string that combines the label and the unit, formatted as "label unit", or just the label if the unit is empty or NULL.
constructLabelWithUnit("Temperature", "Celsius") # Returns "Temperature [Celsius]" constructLabelWithUnit("Length", "") # Returns "Length" constructLabelWithUnit(NULL, "kg") # Returns NULLconstructLabelWithUnit("Temperature", "Celsius") # Returns "Temperature [Celsius]" constructLabelWithUnit("Length", "") # Returns "Length" constructLabelWithUnit(NULL, "kg") # Returns NULL
A data frame containing example covariate data used in the vignette for demonstrating histogram plotting functionality with different grouping variables.
data(exampleDataCovariates)data(exampleDataCovariates)
A data frame with covariate information typically used in population pharmacokinetic/pharmacodynamic analyses.
Generated for package demonstration purposes.
vignette("Histogram Plots", package = "ospsuite.plots")
A data frame containing example pharmacokinetic time profile data used in the vignette for demonstrating time profile plotting functionality.
data(exampleDataTimeProfile)data(exampleDataTimeProfile)
A data frame with time-series pharmacokinetic data containing variables typically used for concentration-time profiles in PBPK modeling.
Generated for package demonstration purposes.
vignette("Time Profile Plots", package = "ospsuite.plots")
This function exports a ggplot object to a specified file with customizable options.
exportPlot( plotObject, filepath, filename, width = NULL, height = NULL, device = NULL, ... )exportPlot( plotObject, filepath, filename, width = NULL, height = NULL, device = NULL, ... )
plotObject |
A ggplot object to be exported. |
filepath |
A character string specifying the directory to save the plot. |
filename |
A character string specifying the name of the file (without path). |
width |
A numeric value specifying the width of the plot. If NULL, the default option is used. |
height |
A numeric value specifying the height of the plot. If NULL, it is calculated based on the plot dimensions. |
device |
Export device, if NULL (default) the device set by ospsuite.plots.exportDevice is used. |
... |
Additional arguments passed to |
The height of the plot is calculated if it is not provided by the user. The calculation takes into account:
The aspect ratio of the plot, which is derived from the theme settings.
The number of rows and columns in the plot layout.
The dimensions of plot components such as axes, legends, and margins. The function ensures that the height is adjusted to maintain the correct aspect ratio based on the specified width.
Options available for plot export with default values:
ospsuite.plots.exportWidth: Width of the exported plot (default = 16).
ospsuite.plots.exportUnits: Units of the exported plot (default = "cm").
ospsuite.plots.exportDevice: File format of the exported plot (default = "png").
ospsuite.plots.exportDpi: Resolution of the exported plot (default = 300).
For more details and examples see the vignettes:
vignette("ospsuite.plots", package = "ospsuite.plots")
NULL, the function saves the plot to the specified file.
## Not run: # Basic usage p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() exportPlot( plotObject = p, filepath = tempdir(), filename = "my_plot.png" ) # Export with custom dimensions and device exportPlot( plotObject = p, filepath = "./output", filename = "scatter_plot", width = 12, height = 8, device = "pdf" ) # Export with special characters in filename (will be cleaned) exportPlot( plotObject = p, filepath = tempdir(), filename = "concentration in µg/L: results" ) ## End(Not run)## Not run: # Basic usage p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() exportPlot( plotObject = p, filepath = tempdir(), filename = "my_plot.png" ) # Export with custom dimensions and device exportPlot( plotObject = p, filepath = "./output", filename = "scatter_plot", width = 12, height = 8, device = "pdf" ) # Export with special characters in filename (will be cleaned) exportPlot( plotObject = p, filepath = tempdir(), filename = "concentration in µg/L: results" ) ## End(Not run)
A geom that renders error bars with cap width specified in mm units,
keeping it visually consistent with the linewidth aesthetic, which is
also expressed in mm. Unlike ggplot2::geom_errorbar(),
the cap width is independent of the data coordinate range or axis scale.
Vertical orientation (aes(x, ymin, ymax)) is used by default.
Pass orientation = "x" for horizontal error bars (aes(y, xmin, xmax)).
geom_errorbar_osp( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., orientation = NA, width = 2, lineend = "butt", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_errorbar_osp( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., orientation = NA, width = 2, lineend = "butt", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
orientation |
Orientation of the layer. |
width |
Width of the error bar caps in mm units. Default: |
lineend |
Line end style (round, butt, square). |
na.rm |
Missing values in the range aesthetics are dropped (the
affected cap is simply not drawn) for both |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A ggplot2 layer that can be added to a plot.
Other layers:
GeomErrorbarOsp,
GeomPointOsp,
geom_point_osp(),
stat_qq_osp()
library(ggplot2) df <- data.frame( x = 1:3, y = c(1, 2, 3), ymin = c(0.5, 1.5, 2.5), ymax = c(1.5, 2.5, 3.5) ) ggplot(df, aes(x, y, ymin = ymin, ymax = ymax)) + geom_errorbar_osp(width = 2, linewidth = 0.8)library(ggplot2) df <- data.frame( x = 1:3, y = c(1, 2, 3), ymin = c(0.5, 1.5, 2.5), ymax = c(1.5, 2.5, 3.5) ) ggplot(df, aes(x, y, ymin = ymin, ymax = ymax)) + geom_errorbar_osp(width = 2, linewidth = 0.8)
A geom that renders OSP shapes using grid primitives.
Uses shape names from ospShapeNames. Automatically applies
scale_shape_osp() when added to a plot (unless a shape scale
is already present).
geom_point_osp( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_point_osp( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A ggplot2 layer that can be added to a plot.
Other layers:
GeomErrorbarOsp,
GeomPointOsp,
geom_errorbar_osp(),
stat_qq_osp()
library(ggplot2) df <- data.frame(x = 1:5, y = 1:5, shape = ospShapeNames[1:5]) ggplot(df, aes(x, y, shape = shape)) + geom_point_osp(size = 4) + scale_shape_osp_identity()library(ggplot2) df <- data.frame(x = 1:5, y = 1:5, shape = ospShapeNames[1:5]) ggplot(df, aes(x, y, shape = shape)) + geom_point_osp(size = 4) + scale_shape_osp_identity()
ggproto object for OSP error bars with cap width in mm units.
Use geom_errorbar_osp() to add this geom to a ggplot.
Other layers:
GeomPointOsp,
geom_errorbar_osp(),
geom_point_osp(),
stat_qq_osp()
ggproto object for OSP point shapes.
Other layers:
GeomErrorbarOsp,
geom_errorbar_osp(),
geom_point_osp(),
stat_qq_osp()
vignette("ospsuite.plots", package = "ospsuite.plots") how to change defaultsget the defaults for the geom attributes used as defaults in plot functions
see vignette("ospsuite.plots", package = "ospsuite.plots") how to change defaults
getDefaultGeomAttributes(geom)getDefaultGeomAttributes(geom)
geom |
type of geom to return attributes |
list with default attributes
Other setDefault functions:
colorMaps,
getDefaultOptions(),
getOspsuite.plots.option(),
resetDefaultColorMapDistinct(),
resetDefaultTheme(),
resetDefaults(),
setDefaultColorMapDistinct(),
setDefaultTheme(),
setDefaults(),
setOspsuite.plots.option()
get list of default options
getDefaultOptions()getDefaultOptions()
names list with default options
Other setDefault functions:
colorMaps,
getDefaultGeomAttributes(),
getOspsuite.plots.option(),
resetDefaultColorMapDistinct(),
resetDefaultTheme(),
resetDefaults(),
setDefaultColorMapDistinct(),
setDefaultTheme(),
setDefaults(),
setOspsuite.plots.option()
this list is used as input for plotRatioVsCov, plotPredVsObs
getFoldDistanceList(folds = c(1.5, 2), includeIdentity = TRUE)getFoldDistanceList(folds = c(1.5, 2), includeIdentity = TRUE)
folds |
of folds e.g. c(1.5,2) must be >1 |
includeIdentity |
A |
named list with fold distances
returns an option value for a option defined by the package OSPSuite.plots
getOspsuite.plots.option(optionKey)getOspsuite.plots.option(optionKey)
optionKey |
identifier of option |
option value
Other setDefault functions:
colorMaps,
getDefaultGeomAttributes(),
getDefaultOptions(),
resetDefaultColorMapDistinct(),
resetDefaultTheme(),
resetDefaults(),
setDefaultColorMapDistinct(),
setDefaultTheme(),
setDefaults(),
setOspsuite.plots.option()
## Not run: getOspsuite.plots.option(optionKey = OptionKeys$watermarkEnabled) ## End(Not run)## Not run: getOspsuite.plots.option(optionKey = OptionKeys$watermarkEnabled) ## End(Not run)
This function creates a ggplot object and adds a watermark if the watermark option is enabled. The watermark can be customized with various options such as position, angle, font size, color, and transparency.
ggplotWithWatermark(...)ggplotWithWatermark(...)
... |
Arguments to be passed to |
If the watermark feature is enabled, the resulting ggplot object will include a watermark overlay when printed. The watermark's properties are determined by options set in the Ospsuite plotting configuration.
The following options can be used to customize the watermark:
watermarkLabel: Text to be displayed as the watermark.
watermarkFormat: A list with the following entries:
x: The x-coordinate for the watermark's position on the plot.
y: The y-coordinate for the watermark's position on the plot.
angle: The angle at which the watermark text is displayed (in degrees).
fontsize: The size of the font for the watermark text.
color: The color of the watermark text, specified in a valid color format (e.g., "red", "#FF0000").
alpha: The transparency level of the watermark text, ranging from 0 (completely transparent) to 1 (completely opaque).
A ggplot object, which may have the class "ggWatermark" if the watermark is enabled. The object can be printed or further modified as needed.
Other watermark:
addWatermark(),
plot.ggWatermark(),
print.ggWatermark()
# Example usage with watermark enabled (watermark is enabled by default) plotWithWatermark <- ggplotWithWatermark(data = mtcars, aes(x = wt, y = mpg)) + geom_point() print(plotWithWatermark) # Example usage with watermark disabled setOspsuite.plots.option(optionKey = OptionKeys$watermarkEnabled, value = FALSE) plotWithoutWatermark <- ggplotWithWatermark(data = mtcars, aes(x = wt, y = mpg)) + geom_point() print(plotWithoutWatermark) # Reset options setOspsuite.plots.option(optionKey = OptionKeys$watermarkEnabled, value = TRUE) # Example usage with customized watermark setOspsuite.plots.option(optionKey = OptionKeys$watermarkLabel, value = "Custom Label") watermarkFormat <- getOspsuite.plots.option(optionKey = OptionKeys$watermarkFormat) watermarkFormat$color <- "red" setOspsuite.plots.option(optionKey = OptionKeys$watermarkFormat, value = watermarkFormat) plotWithCustomizedWatermark <- ggplotWithWatermark(data = mtcars, aes(x = wt, y = mpg)) + geom_point() print(plotWithCustomizedWatermark) # Reset options setOspsuite.plots.option( optionKey = OptionKeys$watermarkFormat, value = getDefaultOptions()[[OptionKeys$watermarkFormat]] ) setOspsuite.plots.option( optionKey = OptionKeys$watermarkLabel, value = getDefaultOptions()[[OptionKeys$watermarkLabel]] )# Example usage with watermark enabled (watermark is enabled by default) plotWithWatermark <- ggplotWithWatermark(data = mtcars, aes(x = wt, y = mpg)) + geom_point() print(plotWithWatermark) # Example usage with watermark disabled setOspsuite.plots.option(optionKey = OptionKeys$watermarkEnabled, value = FALSE) plotWithoutWatermark <- ggplotWithWatermark(data = mtcars, aes(x = wt, y = mpg)) + geom_point() print(plotWithoutWatermark) # Reset options setOspsuite.plots.option(optionKey = OptionKeys$watermarkEnabled, value = TRUE) # Example usage with customized watermark setOspsuite.plots.option(optionKey = OptionKeys$watermarkLabel, value = "Custom Label") watermarkFormat <- getOspsuite.plots.option(optionKey = OptionKeys$watermarkFormat) watermarkFormat$color <- "red" setOspsuite.plots.option(optionKey = OptionKeys$watermarkFormat, value = watermarkFormat) plotWithCustomizedWatermark <- ggplotWithWatermark(data = mtcars, aes(x = wt, y = mpg)) + geom_point() print(plotWithCustomizedWatermark) # Reset options setOspsuite.plots.option( optionKey = OptionKeys$watermarkFormat, value = getDefaultOptions()[[OptionKeys$watermarkFormat]] ) setOspsuite.plots.option( optionKey = OptionKeys$watermarkLabel, value = getDefaultOptions()[[OptionKeys$watermarkLabel]] )
Initialize a ggplot object with a watermark and set its labels by metaData.
initializePlot(mappedData = NULL, setMapping = TRUE)initializePlot(mappedData = NULL, setMapping = TRUE)
mappedData |
A |
setMapping |
A boolean indicating if TRUE (default) mapping is passed to ggplot; otherwise, mapping will be used only to create labels. |
A ggplot object.
R6 class for mapping variables to data
datadata.frame used for mapping
mappinglist of aesthetic mappings
dimensionslist with dimensions of mapping
unitslist with dimensions of mapping
columnClasseslist with class of mapped columns
xlimitsdouble vector limits of primary y axis
ylimitsdouble vector limits of primary y axis
hasLLOQMatchboolean if TRUE data has matched lloq data
dataForPlotreturns data used for plotting, may be adjusted in child classes (e.g. 2 axis in MappedDataTimeProfile) check if aesthetic is available in data returns data column for aesthetic adds and update mapping deletes data where mdv is 1
adds new column isLLOQ.i and updates boolean LLOQMatch
adds new columns ymin and ymax if required
copy aesthetics groupby, but only if not explicit set
converts Integer columns, which are no factors to double
factorize column for group to factor
MappedData$new()Create a new MappedData object
MappedData$new( data, mapping, xScale, yScale, groupAesthetics = NULL, groupOrder = NULL, direction = "y", isObserved = TRUE, xlimits = NULL, ylimits = NULL )
datadata.frame used for mapping
mappinglist of aesthetic mappings
xScalescale of x-axis either 'linear' or 'log'
yScalescale of y-axis either 'linear' or 'log'
groupAestheticsvector of aesthetics, which are used for columns mapped with groupby
groupOrderlabels and order for group aesthetic
directiondirection of plot either "x" or "y"
isObservedA boolean if TRUE mappings mdv, lloq
xlimitslimits for x-axis (may be NULL)
ylimitslimits for y-axis (may be NULL)
A new MappedData object
filter possible aesthetics for a geom,
check if mandatory are available
MappedData$getAestheticsForGeom()MappedData$getAestheticsForGeom(geom, geomAttributes)
geomtype of geometric object
geomAttributesadditionally arguments for geom layer, will overwrite aesthetics
list of accepted mappings adds list with dimension, units and column classes
MappedData$addMetaData()MappedData$addMetaData(metaData)
metaDataA named list of information about data such as the dimension and unit of its variables.
updated MappedData object
check if unit of scale direction is time and sets the breaks accordingly
MappedData$updateScaleArgumentsForTimeUnit()MappedData$updateScaleArgumentsForTimeUnit(scaleArgs, scaleDirection = "x")
scaleArgsadditional arguments passed on to scale function
scaleDirectiondirection of axis either 'x' or 'y'
scaleArgs with adjusted break function
MappedData$clone()The objects of this class are cloneable with this method.
MappedData$clone(deep = FALSE)
deepWhether to make a deep clone.
Other MappedData classes:
MappedDataBoxplot,
MappedDataRangeDistribution,
MappedDataTimeProfile
R6 class for mapping variable to data for boxplot visualizations. This class extends MappedData to provide specialized mapping functionality for box-and-whisker plots, including handling of discrete and continuous x-axis scales and automatic grouping logic.
MappedData -> MappedDataBoxplot
xScalescale of x axis
xScaleArgsarguments for scale of x axis
hasXmappingboolean, if TRUE x is mapped
boxwhiskerMappingmapping for box whisker plot
MappedDataBoxplot$new()Create a new MappedDataBoxplot object
MappedDataBoxplot$new( data, mapping, groupAesthetics = NULL, direction = "y", isObserved = TRUE, xlimits = NULL, ylimits = NULL, xScale = AxisScales$linear, yScale = AxisScales$linear )
datadata.frame used for mapping
mappinglist of aesthetic mappings
groupAestheticsvector of aesthetics, which are used for columns mapped with aesthetic groupby
directiondirection of plot either "x" or "y"
isObservedA boolean if TRUE mappings mdv, lloq, error and error_relative are evaluated
xlimitslimits for x-axis (may be NULL)
ylimitslimits for y-axis (may be NULL)
xScalescale of x-axis either 'linear' or 'log'
yScalescale of y-axis either 'linear' or 'log'
MappedDataBoxplot class object
use Metadata to adjust binning of x-axis, and group aesthetic
MappedDataBoxplot$doAdjustmentsWithMetaData()MappedDataBoxplot$doAdjustmentsWithMetaData( originalmapping, xScale, xScaleArgs )
originalmappingmapping provided by user
xScaleeither 'linear','log', 'discrete' or 'auto' (default) auto select linear for continuous data and discrete for categorical data
xScaleArgslist of arguments passed to ggplot2::scale_x_continuous(), ggplot2::scale_x_log10() or
ggplot2::scale_x_discrete()
adjusted MappedDataBoxplot class object
MappedDataBoxplot$clone()The objects of this class are cloneable with this method.
MappedDataBoxplot$clone(deep = FALSE)
deepWhether to make a deep clone.
Other MappedData classes:
MappedData,
MappedDataRangeDistribution,
MappedDataTimeProfile
## Not run: # Create boxplot mapping with continuous x variable boxplotData <- MappedDataBoxplot$new( data = myDataFrame, mapping = aes(x = dose, y = concentration), xScale = "linear" ) # Create boxplot mapping with categorical x variable boxplotData <- MappedDataBoxplot$new( data = myDataFrame, mapping = aes(x = treatment_group, y = response), xScale = "discrete" ) ## End(Not run)## Not run: # Create boxplot mapping with continuous x variable boxplotData <- MappedDataBoxplot$new( data = myDataFrame, mapping = aes(x = dose, y = concentration), xScale = "linear" ) # Create boxplot mapping with categorical x variable boxplotData <- MappedDataBoxplot$new( data = myDataFrame, mapping = aes(x = treatment_group, y = response), xScale = "discrete" ) ## End(Not run)
R6 class for mapping variable to data
MappedData -> MappedDataRangeDistribution
xScalescale of x axis
borderborders of the binning.
MappedDataRangeDistribution$new()Create a new MappedDataRangeDistribution object
MappedDataRangeDistribution$new( data, mapping, groupAesthetics = NULL, direction = "y", isObserved = TRUE, xlimits = NULL, ylimits = NULL, xScale = "linear", yScale = "linear", modeOfBinning = NA, numberOfBins = NA, breaks = NA )
datadata.frame used for mapping
mappinglist of aesthetic mappings
groupAestheticsvector of aesthetics, which are used for columns mapped with aesthetic groupby
directiondirection of plot either "x" or "y"
isObservedA boolean if TRUE mappings mdv, lloq, error and error_relative are evaluated
xlimitslimits for x-axis (may be NULL)
ylimitslimits for y-axis (may be NULL)
xScalescale of x-axis either 'linear' or 'log'
yScalescale of y-axis either 'linear' or 'log'
modeOfBinningmethod of binning (e.g., 'breaks', 'number', 'interval')
numberOfBinsnumber of bins to use for binning
breaksbreaks for binning if modeOfBinning is 'breaks'
MappedDataRangeDistribution class object
Set binning columns
MappedDataRangeDistribution$setBins()This method sets the bins for the data based on the specified mode of binning.
MappedDataRangeDistribution$setBins()
The object itself (invisible) Create a data table with bin border information
MappedDataRangeDistribution$setBorderDataTable()This method sets up a data table containing border information for the bins. Set x mapping for the plot
MappedDataRangeDistribution$setBorderDataTable(identifier = "IndividualId")
identifierIdentifier for the data table (default is 'IndividualId')
MappedDataRangeDistribution$setXMapping()This method sets the x mapping for the plot based on the specified parameters.
MappedDataRangeDistribution$setXMapping(asStepPlot)
asStepPlotLogical indicating if the plot should be a step plot.
MappedDataRangeDistribution$clone()The objects of this class are cloneable with this method.
MappedDataRangeDistribution$clone(deep = FALSE)
deepWhether to make a deep clone.
Other MappedData classes:
MappedData,
MappedDataBoxplot,
MappedDataTimeProfile
R6 class for mapping variable to data for time profile visualizations. This class extends MappedData to provide specialized functionality for time-series plots, including support for secondary y-axes, dual scaling, and time-specific axis handling.
This class is specifically designed for pharmacokinetic time profile plots where data may need to be displayed on dual y-axes with different scales (linear/log). It handles complex scenarios like mapping simulated and observed data with different scaling requirements.
MappedData -> MappedDataTimeProfile
y2limitsdouble vector limits of secondary y axis
requireDualAxisboolean, If TRUE secondary axis is required
listOfGroupscharacter vector of groupings
secAxissec_axis() object
dataForPlotscaled data used for plotting adjust limits
MappedDataTimeProfile$new()Create a new MappedDataTimeProfile object
MappedDataTimeProfile$new( data, mapping, groupAesthetics = NULL, groupOrder = NULL, direction = "y", isObserved = TRUE, xlimits = NULL, ylimits = NULL, xScale = AxisScales$linear, scaleOfPrimaryAxis = AxisScales$linear, scaleOfSecondaryAxis = AxisScales$linear, y2limits = NULL )
datadata.frame used for mapping
mappinglist of aesthetic mappings
groupAestheticsvector of aesthetics, which are used for columns mapped with aesthetic groupby ,
use of group aesthetics triggers second axis after simulation layers
groupOrderlabels and order for group aesthetic
directiondirection of plot either "x" or "y"
isObservedA boolean if TRUE mappings mdv, lloq are evaluated
xlimitslimits for x-axis (may be NULL)
ylimitslimits for primary axis (may be NULL)
xScale= scale of x-axis
scaleOfPrimaryAxisscale of direction, either "linear" or "log"
scaleOfSecondaryAxiseither 'linear' or 'log'
y2limitslimits for secondary axis (may be NULL)
A new MappedDataTimeProfile object
Scale data for secondary axis and update secAxis transformation
This method handles the complex logic of scaling data between primary and secondary axes with different scale types (linear/log combinations).
MappedDataTimeProfile$scaleDataForSecondaryAxis()MappedDataTimeProfile$scaleDataForSecondaryAxis( ylimits = NULL, y2limits = NULL, y2ScaleArgs = list() )
ylimitslimits for primary axis (may be NULL)
y2limitslimits for secondary axis (may be NULL)
y2ScaleArgsarguments for secondary axis
updated MappedDataTimeProfile boolean for secondary axis
MappedDataTimeProfile$clone()The objects of this class are cloneable with this method.
MappedDataTimeProfile$clone(deep = FALSE)
deepWhether to make a deep clone.
Other MappedData classes:
MappedData,
MappedDataBoxplot,
MappedDataRangeDistribution
## Not run: # Create time profile mapping with secondary axis timeData <- MappedDataTimeProfile$new( data = myDataFrame, mapping = aes(x = time, y = concentration, y2axis = fraction_unbound), scaleOfPrimaryAxis = "linear", scaleOfSecondaryAxis = "log" ) # Time profile with grouping aesthetics timeData <- MappedDataTimeProfile$new( data = myDataFrame, mapping = aes(x = time, y = concentration, color = compound), groupAesthetics = c("color", "linetype") ) ## End(Not run)## Not run: # Create time profile mapping with secondary axis timeData <- MappedDataTimeProfile$new( data = myDataFrame, mapping = aes(x = time, y = concentration, y2axis = fraction_unbound), scaleOfPrimaryAxis = "linear", scaleOfSecondaryAxis = "log" ) # Time profile with grouping aesthetics timeData <- MappedDataTimeProfile$new( data = myDataFrame, mapping = aes(x = time, y = concentration, color = compound), groupAesthetics = c("color", "linetype") ) ## End(Not run)
converts metaData List to a data frame row names specify properties
metaData2DataFrame(metaData)metaData2DataFrame(metaData)
metaData |
A named list of information about the |
metaData as data.frame
enumeration keys for OSPSuite.plots options
OptionKeysOptionKeys
Character vector of all available OSP shape names.
ospShapeNamesospShapeNames
Other shapes:
Shapes,
scale_shape_osp(),
scale_shape_osp_identity(),
scale_shape_osp_manual()
This method allows for the ggWatermark object to be plotted using the standard print method.
## S3 method for class 'ggWatermark' plot(x, ...)## S3 method for class 'ggWatermark' plot(x, ...)
x |
A ggWatermark object to be printed. |
... |
Additional arguments to be passed to the print method. |
Other watermark:
addWatermark(),
ggplotWithWatermark(),
print.ggWatermark()
Produces box-and-whisker plots for visualizing the distribution of data. For more details and examples, see the vignettes:
vignette("Box-Whisker Plots", package = "ospsuite.plots")
vignette("ospsuite.plots", package = "ospsuite.plots")
plotBoxWhisker( data, mapping, metaData = NULL, plotObject = NULL, percentiles = getOspsuite.plots.option(optionKey = OptionKeys$percentiles), yScale = AxisScales$linear, yScaleArgs = list(), xScale = "auto", xScaleArgs = list(), statFun = NULL, outliers = FALSE, statFunOutlier = NULL, geomBoxplotAttributes = getDefaultGeomAttributes("Boxplot"), geomPointAttributes = getDefaultGeomAttributes("Boxplot"), residualScale = NULL )plotBoxWhisker( data, mapping, metaData = NULL, plotObject = NULL, percentiles = getOspsuite.plots.option(optionKey = OptionKeys$percentiles), yScale = AxisScales$linear, yScaleArgs = list(), xScale = "auto", xScaleArgs = list(), statFun = NULL, outliers = FALSE, statFunOutlier = NULL, geomBoxplotAttributes = getDefaultGeomAttributes("Boxplot"), geomPointAttributes = getDefaultGeomAttributes("Boxplot"), residualScale = NULL )
data |
A |
mapping |
A list of aesthetic mappings to use for the plot. |
metaData |
A named list of information about |
plotObject |
An optional |
percentiles |
A numeric vector with percentiles used for the box whiskers and boxes,
e.g., c(0.05, 0.25, 0.5, 0.75, 0.95). Default defined by |
yScale |
either 'linear' then |
yScaleArgs |
list of arguments passed to |
xScale |
Either 'linear', 'log', 'discrete', or 'auto' (default). Auto selects linear for continuous data and discrete for categorical data. |
xScaleArgs |
A list of arguments passed to |
statFun |
(default NULL) A function to calculate whiskers and box ranges,
which overwrites the |
outliers |
Logical indicating whether outliers should be included in the boxplot. Outliers are flagged when outside the range from the "25th" percentile - 1.5 x IQR to the "75th" percentile + 1.5 x IQR, as suggested by McGill et al. |
statFunOutlier |
(default NULL) A function to calculate outliers, which overwrites the default calculation if provided. |
geomBoxplotAttributes |
A |
geomPointAttributes |
A |
residualScale |
Deprecated. Retained for backward compatibility only.
Non- |
A ggplot object representing the box-whisker plot.
McGill, R., Tukey, J. W., & Larsen, W. A. (1978). Variations of box plots. The American Statistician, 32(1), 12-16.
Other plot functions:
plotForest(),
plotHistogram(),
plotPredVsObs(),
plotQQ(),
plotRangeDistribution(),
plotRatioVsCov(),
plotResVsCov(),
plotTimeProfile(),
plotYVsX()
## Not run: # Basic box-whisker plot plotBoxWhisker( data = myData, mapping = aes(x = group, y = value) ) # Box-whisker plot with custom percentiles plotBoxWhisker( data = myData, mapping = aes(x = treatment, y = response), percentiles = c(0.1, 0.25, 0.5, 0.75, 0.9) ) # Box-whisker plot with custom stat function customStatFun <- function(x) { return(quantile(x, probs = c(0.05, 0.25, 0.5, 0.75, 0.95), na.rm = TRUE)) } plotBoxWhisker( data = myData, mapping = aes(x = dose_group, y = concentration), statFun = customStatFun, outliers = TRUE ) ## End(Not run)## Not run: # Basic box-whisker plot plotBoxWhisker( data = myData, mapping = aes(x = group, y = value) ) # Box-whisker plot with custom percentiles plotBoxWhisker( data = myData, mapping = aes(x = treatment, y = response), percentiles = c(0.1, 0.25, 0.5, 0.75, 0.9) ) # Box-whisker plot with custom stat function customStatFun <- function(x) { return(quantile(x, probs = c(0.05, 0.25, 0.5, 0.75, 0.95), na.rm = TRUE)) } plotBoxWhisker( data = myData, mapping = aes(x = dose_group, y = concentration), statFun = customStatFun, outliers = TRUE ) ## End(Not run)
This function generates a forest plot with optional faceting and a corresponding table.
plotForest( plotData, mapping = aes(y = y, x = x, groupby = dataType), xLabel, yFacetColumns = NULL, xFacetColumn = NULL, xScale = c("linear", "log"), xScaleArgs = list(), groupAesthetics = c("color", "fill", "shape"), tableColumns = c("yValues", "yErrorValues"), tableLabels = c("M", "Variance"), labelWrapWidth = 10, digitsToRound = 2, digitsToShow = 2, withTable = is.null(xFacetColumn), geomPointAttributes = getDefaultGeomAttributes("Point"), geomErrorbarAttributes = getDefaultGeomAttributes("Errorbar"), facetScales = c("free_y", "free") )plotForest( plotData, mapping = aes(y = y, x = x, groupby = dataType), xLabel, yFacetColumns = NULL, xFacetColumn = NULL, xScale = c("linear", "log"), xScaleArgs = list(), groupAesthetics = c("color", "fill", "shape"), tableColumns = c("yValues", "yErrorValues"), tableLabels = c("M", "Variance"), labelWrapWidth = 10, digitsToRound = 2, digitsToShow = 2, withTable = is.null(xFacetColumn), geomPointAttributes = getDefaultGeomAttributes("Point"), geomErrorbarAttributes = getDefaultGeomAttributes("Errorbar"), facetScales = c("free_y", "free") )
plotData |
A data.table containing the data to be plotted. Must include columns specified in |
mapping |
A ggplot2 mapping object, typically created with |
xLabel |
A string representing the label for the x-axis. |
yFacetColumns |
A character vector of column names used for faceting on the y-axis. Can be NULL or of length up to 2. |
xFacetColumn |
A character string specifying the column name for the x-axis facet. Must be of length 1 or NULL. |
xScale |
A character string indicating the scale type for the x-axis. Options are "linear" or "log". |
xScaleArgs |
A list of additional arguments for customizing the x-axis scale. |
groupAesthetics |
A character vector specifying aesthetics for grouping (e.g., color, fill, shape). |
tableColumns |
A character vector of column names to be included in the table. |
tableLabels |
A character vector of labels corresponding to |
labelWrapWidth |
A numeric value specifying the width for label wrapping in facets. |
digitsToRound |
An integer specifying the number of digits to round in the table. |
digitsToShow |
An integer specifying the number of digits to display in the table. |
withTable |
A logical flag indicating whether to include the table in the output. Defaults to TRUE if |
geomPointAttributes |
A list of attributes for the point geometry in the plot. |
geomErrorbarAttributes |
A list of attributes for the error bar geometry in the plot. |
facetScales |
A character string indicating the scales used for facets. Options are "free_y" or "free". |
A combined plot object containing the forest plot and the table (if applicable).
Other plot functions:
plotBoxWhisker(),
plotHistogram(),
plotPredVsObs(),
plotQQ(),
plotRangeDistribution(),
plotRatioVsCov(),
plotResVsCov(),
plotTimeProfile(),
plotYVsX()
Produces histograms with optional distribution fit.
For more details and examples see the vignettes:
vignette("Histogram Plots", package = "ospsuite.plots")
vignette("ospsuite.plots", package = "ospsuite.plots")
vignette("Goodness of fit", package = "ospsuite.plots")
plotHistogram( data, mapping, metaData = NULL, asBarPlot = NULL, geomHistAttributes = getDefaultGeomAttributes("Hist"), plotAsFrequency = FALSE, xScale = AxisScales$linear, xScaleArgs = list(), yScale = AxisScales$linear, yScaleArgs = list(), distribution = "none", meanFunction = "auto", residualScale = NULL )plotHistogram( data, mapping, metaData = NULL, asBarPlot = NULL, geomHistAttributes = getDefaultGeomAttributes("Hist"), plotAsFrequency = FALSE, xScale = AxisScales$linear, xScaleArgs = list(), yScale = AxisScales$linear, yScaleArgs = list(), distribution = "none", meanFunction = "auto", residualScale = NULL )
data |
data.frame with simulated data will be displayed as lines with ribbons |
mapping |
a list of aesthetic mappings to use for plot,
additional to |
metaData |
A named list of information about |
asBarPlot |
A |
geomHistAttributes |
A |
plotAsFrequency |
A |
xScale |
either 'linear' then |
xScaleArgs |
list of arguments passed to |
yScale |
either 'linear' then |
yScaleArgs |
list of arguments passed to |
distribution |
Name of the distribution to fit. Available distributions are those in the |
meanFunction |
Function selection for the display of a vertical line. Options: |
residualScale |
Deprecated. Retained for backward compatibility only.
Non- |
A ggplot object.
Other plot functions:
plotBoxWhisker(),
plotForest(),
plotPredVsObs(),
plotQQ(),
plotRangeDistribution(),
plotRatioVsCov(),
plotResVsCov(),
plotTimeProfile(),
plotYVsX()
This function is a wrapper for plotYVsX with adjusted input parameters.
The following parameters are fixed and cannot be set:
observedDataDirection = "x"
For details and examples, see the vignettes:
vignette("Goodness of fit", package = "ospsuite.plots")
vignette("ospsuite.plots", package = "ospsuite.plots")
plotPredVsObs( data = NULL, mapping = NULL, xyScale = AxisScales$log, comparisonLineVector = getFoldDistanceList(c(1.5, 2)), asSquarePlot = TRUE, ... )plotPredVsObs( data = NULL, mapping = NULL, xyScale = AxisScales$log, comparisonLineVector = getFoldDistanceList(c(1.5, 2)), asSquarePlot = TRUE, ... )
data |
A |
mapping |
A list of aesthetic mappings to use for the plot. |
xyScale |
Either "linear" or "log" scale for the X and Y axes. |
comparisonLineVector |
A vector defining the comparison lines. |
asSquarePlot |
A boolean; if true, the plot is returned as a square plot with aspect ratio = 1 and fixed ratios. |
... |
Arguments passed on to
|
A ggplot object representing the predicted vs observed plots.
Other plot functions:
plotBoxWhisker(),
plotForest(),
plotHistogram(),
plotQQ(),
plotRangeDistribution(),
plotRatioVsCov(),
plotResVsCov(),
plotTimeProfile(),
plotYVsX()
For details and examples see the vignettes:
vignette("Goodness of fit", package = "ospsuite.plots")
vignette("ospsuite.plots", package = "ospsuite.plots")
plotQQ( data, mapping, metaData = NULL, xScaleArgs = list(), yScaleArgs = list(), geomQQAttributes = list(), geomQQLineAttributes = geomQQAttributes, groupAesthetics = c("colour", "fill", "shape"), residualScale = NULL )plotQQ( data, mapping, metaData = NULL, xScaleArgs = list(), yScaleArgs = list(), geomQQAttributes = list(), geomQQLineAttributes = geomQQAttributes, groupAesthetics = c("colour", "fill", "shape"), residualScale = NULL )
data |
´data.frame' with data to plot |
mapping |
a list of aesthetic mappings to use for plot,
additional to |
metaData |
A named list of information about |
xScaleArgs |
list of arguments passed to |
yScaleArgs |
list of arguments passed to |
geomQQAttributes |
A list of arguments passed to |
geomQQLineAttributes |
A list of arguments passed to |
groupAesthetics |
A character vector of aesthetic names used for grouping data points in the Q-Q plot.
Common options include |
residualScale |
Deprecated. Retained for backward compatibility only.
Non- |
A ggplot object
Other plot functions:
plotBoxWhisker(),
plotForest(),
plotHistogram(),
plotPredVsObs(),
plotRangeDistribution(),
plotRatioVsCov(),
plotResVsCov(),
plotTimeProfile(),
plotYVsX()
Creates a range plot using specified data and mapping, allowing for different binning strategies and scaling options. This function provides a flexible way to visualize data distributions over specified ranges with optional statistical summaries.
plotRangeDistribution( data, mapping, metaData = NULL, modeOfBinning = BINNINGMODE$number, numberOfBins = 20, breaks = NA, asStepPlot = FALSE, statFun = NULL, percentiles = getOspsuite.plots.option(optionKey = OptionKeys$defaultPercentiles), yScale = "linear", yScaleArgs = list(), xScale = "linear", xScaleArgs = list(), geomRibbonAttributes = getDefaultGeomAttributes("Ribbon"), geomLineAttributes = getDefaultGeomAttributes("Line"), identifier = "IndividualId" )plotRangeDistribution( data, mapping, metaData = NULL, modeOfBinning = BINNINGMODE$number, numberOfBins = 20, breaks = NA, asStepPlot = FALSE, statFun = NULL, percentiles = getOspsuite.plots.option(optionKey = OptionKeys$defaultPercentiles), yScale = "linear", yScaleArgs = list(), xScale = "linear", xScaleArgs = list(), geomRibbonAttributes = getDefaultGeomAttributes("Ribbon"), geomLineAttributes = getDefaultGeomAttributes("Line"), identifier = "IndividualId" )
data |
A data frame containing the data to be plotted. This data should include the variables specified in the |
mapping |
A mapping object (created using |
metaData |
Optional metadata to be added to the plot. This can include additional information relevant to the data being plotted. |
modeOfBinning |
A character string specifying the mode of binning. It determines how the data will be divided into bins. Options include:
|
numberOfBins |
An integer specifying the number of bins to use for equal frequency or width binning. Default is 20. |
breaks |
Optional numeric vector specifying custom breaks for binning when |
asStepPlot |
A logical indicating whether to create a step plot. If TRUE, the plot will display steps between the data points rather than continuous lines. Default is FALSE. |
statFun |
An optional function for statistical summary, which takes a vector of y-values and returns a summary (e.g., quantiles). If NULL, defaults to calculating quantiles based on the specified |
percentiles |
A numeric vector of percentiles to be used in the statistical summary, which defines the range of values to be displayed on the plot. Default is the 5th, 50th, and 95th percentiles. |
yScale |
A character string specifying the y-axis scale. Options are "linear" or "log". This determines how the y values are displayed on the plot. Default is "linear". |
yScaleArgs |
A list of additional arguments for the y-axis scale, which can be used to customize the appearance and behavior of the y-axis. |
xScale |
A character string specifying the x-axis scale. Options are "linear" or "log". This determines how the x values are displayed on the plot. Default is "linear". |
xScaleArgs |
A list of additional arguments for the x-axis scale, which can be used to customize the appearance and behavior of the x-axis. |
geomRibbonAttributes |
A list of attributes for the ribbon geometry in the plot, allowing customization of the visual appearance, such as colors and transparency. |
geomLineAttributes |
A list of attributes for the line geometry in the plot, allowing customization of line characteristics such as color, size, and type. |
identifier |
columnName of individual identifiers, default "IndividualId" |
A ggplot object representing the range plot. The returned object can be further customized or rendered using print() or similar functions.
Other plot functions:
plotBoxWhisker(),
plotForest(),
plotHistogram(),
plotPredVsObs(),
plotQQ(),
plotRatioVsCov(),
plotResVsCov(),
plotTimeProfile(),
plotYVsX()
This function is a wrapper for plotYVsX with adjusted input parameters.
The following parameters are fixed and cannot be set:
observedDataDirection = "y"
yDisplayAsAbsolute = FALSE
For details and examples, see the vignettes:
vignette("Goodness of fit", package = "ospsuite.plots")
vignette("ospsuite.plots", package = "ospsuite.plots")
plotRatioVsCov( data = NULL, mapping = NULL, addGuestLimits = FALSE, yScale = AxisScales$log, xScale = ifelse(addGuestLimits, AxisScales$log, AxisScales$linear), comparisonLineVector = getFoldDistanceList(c(1.5, 2)), deltaGuest = 1, residualScale = NULL, ... )plotRatioVsCov( data = NULL, mapping = NULL, addGuestLimits = FALSE, yScale = AxisScales$log, xScale = ifelse(addGuestLimits, AxisScales$log, AxisScales$linear), comparisonLineVector = getFoldDistanceList(c(1.5, 2)), deltaGuest = 1, residualScale = NULL, ... )
data |
A |
mapping |
A list of aesthetic mappings to use for the plot. |
addGuestLimits |
A boolean that activates the insertion of guest limits. |
yScale |
either 'linear' then |
xScale |
either 'linear' then |
comparisonLineVector |
A vector defining the comparison lines. |
deltaGuest |
Numeric value parameter for the Guest function. |
residualScale |
Deprecated. Retained for backward compatibility only.
Non- |
... |
Arguments passed on to
|
A ggplot object representing the ratio plots.
Other plot functions:
plotBoxWhisker(),
plotForest(),
plotHistogram(),
plotPredVsObs(),
plotQQ(),
plotRangeDistribution(),
plotResVsCov(),
plotTimeProfile(),
plotYVsX()
This function is a wrapper for plotYVsX with adjusted input parameters.
The following parameters are fixed and cannot be set:
observedDataDirection = "y"
yDisplayAsAbsolute = FALSE
addGuestLimits = FALSE (use plotRatio() if needed)
For details and examples, see the vignettes:
vignette("Goodness of fit", package = "ospsuite.plots")
vignette("ospsuite.plots", package = "ospsuite.plots")
plotResVsCov( data, mapping, comparisonLineVector = 0, yScale = AxisScales$linear, residualScale = NULL, ... )plotResVsCov( data, mapping, comparisonLineVector = 0, yScale = AxisScales$linear, residualScale = NULL, ... )
data |
A |
mapping |
A list of aesthetic mappings to use for the plot. |
comparisonLineVector |
A vector defining the comparison lines. |
yScale |
either 'linear' then |
residualScale |
Deprecated. Retained for backward compatibility only.
Non- |
... |
Arguments passed on to
|
A ggplot object representing the residual plots.
Other plot functions:
plotBoxWhisker(),
plotForest(),
plotHistogram(),
plotPredVsObs(),
plotQQ(),
plotRangeDistribution(),
plotRatioVsCov(),
plotTimeProfile(),
plotYVsX()
Produces time profiles for simulated and observed data.
For the simulated data a geom_line and a geom_ribbon layer are added
For the observed data a geom_point and a geom_errorbar_osp layer are added
For more details and examples see the vignettes:
vignette("Time Profile Plots", package = "ospsuite.plots")
vignette("ospsuite.plots", package = "ospsuite.plots")
plotTimeProfile( data = NULL, mapping = NULL, observedData = NULL, observedMapping = mapping, metaData = NULL, mapSimulatedAndObserved = NULL, xScale = AxisScales$linear, xScaleArgs = list(limits = c(0, NA)), yScale = AxisScales$linear, yScaleArgs = list(), y2Scale = AxisScales$linear, y2ScaleArgs = list(), plotObject = NULL, geomLineAttributes = getDefaultGeomAttributes("Line"), geomRibbonAttributes = getDefaultGeomAttributes("Ribbon"), geomPointAttributes = getDefaultGeomAttributes("Point"), geomErrorbarAttributes = getDefaultGeomAttributes("Errorbar"), geomLLOQAttributes = getDefaultGeomAttributes("LLOQ"), groupAesthetics = c("colour", "fill", "shape") )plotTimeProfile( data = NULL, mapping = NULL, observedData = NULL, observedMapping = mapping, metaData = NULL, mapSimulatedAndObserved = NULL, xScale = AxisScales$linear, xScaleArgs = list(limits = c(0, NA)), yScale = AxisScales$linear, yScaleArgs = list(), y2Scale = AxisScales$linear, y2ScaleArgs = list(), plotObject = NULL, geomLineAttributes = getDefaultGeomAttributes("Line"), geomRibbonAttributes = getDefaultGeomAttributes("Ribbon"), geomPointAttributes = getDefaultGeomAttributes("Point"), geomErrorbarAttributes = getDefaultGeomAttributes("Errorbar"), geomLLOQAttributes = getDefaultGeomAttributes("LLOQ"), groupAesthetics = c("colour", "fill", "shape") )
data |
data.frame with simulated data will be displayed as lines with ribbons |
mapping |
a list of aesthetic mappings to use for plot,
additional to |
observedData |
data.frame with observed data will be displayed as points with error-bars |
observedMapping |
a list of aesthetic mappings to use for observed data,
per default is is set to mapping. So if both data sets have the same mapping, use only |
metaData |
A named list of information about |
mapSimulatedAndObserved |
table with columns observed and simulated which maps simulated and observed data
use of |
xScale |
either 'linear' then |
xScaleArgs |
list of arguments passed to |
yScale |
either 'linear' then |
yScaleArgs |
list of arguments passed to |
y2Scale |
either 'linear' the secondary axis is displayed linear, or 'log' secondary axis is displayed with log scale |
y2ScaleArgs |
list of arguments passed to |
plotObject |
An optional |
geomLineAttributes |
A |
geomRibbonAttributes |
A |
geomPointAttributes |
A |
geomErrorbarAttributes |
A |
geomLLOQAttributes |
A |
groupAesthetics |
vector of aesthetics, which are used for columns mapped with |
A ggplot object
Other plot functions:
plotBoxWhisker(),
plotForest(),
plotHistogram(),
plotPredVsObs(),
plotQQ(),
plotRangeDistribution(),
plotRatioVsCov(),
plotResVsCov(),
plotYVsX()
## Not run: # Basic time profile plot with simulated data plotTimeProfile( data = simulationData, mapping = aes(x = time, y = concentration, color = compound) ) # Time profile with both simulated and observed data plotTimeProfile( data = simulationData, observedData = observedData, mapping = aes(x = time, y = concentration, color = treatment), observedMapping = aes(x = time, y = concentration, color = treatment) ) # Time profile with secondary y-axis plotTimeProfile( data = myData, mapping = aes(x = time, y = concentration, y2axis = fraction_unbound) ) ## End(Not run)## Not run: # Basic time profile plot with simulated data plotTimeProfile( data = simulationData, mapping = aes(x = time, y = concentration, color = compound) ) # Time profile with both simulated and observed data plotTimeProfile( data = simulationData, observedData = observedData, mapping = aes(x = time, y = concentration, color = treatment), observedMapping = aes(x = time, y = concentration, color = treatment) ) # Time profile with secondary y-axis plotTimeProfile( data = myData, mapping = aes(x = time, y = concentration, y2axis = fraction_unbound) ) ## End(Not run)
This function creates a base plot for plotResVsCov(), plotRatioVsCov(), and plotPredVsObs().
For details and examples, see the vignettes:
vignette("Goodness of fit", package = "ospsuite.plots")
vignette("ospsuite.plots", package = "ospsuite.plots")
plotYVsX( data, mapping, metaData = NULL, geomPointAttributes = getDefaultGeomAttributes("Point"), geomErrorbarAttributes = getDefaultGeomAttributes("Errorbar"), geomGuestLineAttributes = getDefaultGeomAttributes("GuestLine"), geomComparisonLineAttributes = getDefaultGeomAttributes("ComparisonLine"), geomLLOQAttributes = getDefaultGeomAttributes("LLOQ"), groupAesthetics = c("colour", "fill", "shape"), comparisonLineVector = NULL, addRegression = FALSE, addGuestLimits = FALSE, deltaGuest = 1, labelGuestCriteria = "guest criteria", residualScale = NULL, asSquarePlot = FALSE, xScale = AxisScales$linear, xScaleArgs = list(), yScale = AxisScales$log, yScaleArgs = list(), observedDataDirection = "y", lloqOnBothAxes = FALSE, yDisplayAsAbsolute = TRUE )plotYVsX( data, mapping, metaData = NULL, geomPointAttributes = getDefaultGeomAttributes("Point"), geomErrorbarAttributes = getDefaultGeomAttributes("Errorbar"), geomGuestLineAttributes = getDefaultGeomAttributes("GuestLine"), geomComparisonLineAttributes = getDefaultGeomAttributes("ComparisonLine"), geomLLOQAttributes = getDefaultGeomAttributes("LLOQ"), groupAesthetics = c("colour", "fill", "shape"), comparisonLineVector = NULL, addRegression = FALSE, addGuestLimits = FALSE, deltaGuest = 1, labelGuestCriteria = "guest criteria", residualScale = NULL, asSquarePlot = FALSE, xScale = AxisScales$linear, xScaleArgs = list(), yScale = AxisScales$log, yScaleArgs = list(), observedDataDirection = "y", lloqOnBothAxes = FALSE, yDisplayAsAbsolute = TRUE )
data |
A |
mapping |
A list of aesthetic mappings to use for the plot. |
metaData |
A named list of information about |
geomPointAttributes |
A |
geomErrorbarAttributes |
A |
geomGuestLineAttributes |
A |
geomComparisonLineAttributes |
A |
geomLLOQAttributes |
A |
groupAesthetics |
A character vector of aesthetic names used for grouping data points when calculating
comparison statistics. Data will be grouped by combinations of these aesthetics before computing counts
and proportions within comparison lines. Common grouping aesthetics include |
comparisonLineVector |
A vector defining the comparison lines. |
addRegression |
A boolean that activates the insertion of a regression line. |
addGuestLimits |
A boolean that activates the insertion of guest limits. |
deltaGuest |
Numeric value parameter for the Guest function. |
labelGuestCriteria |
Label used in the legend for guest criteria (default: "guest criteria"). |
residualScale |
Deprecated. Retained for backward compatibility only.
Non- |
asSquarePlot |
A boolean; if true, the plot is returned as a square plot with aspect ratio = 1 and fixed ratios. |
xScale |
either 'linear' then |
xScaleArgs |
list of arguments passed to |
yScale |
either 'linear' then |
yScaleArgs |
list of arguments passed to |
observedDataDirection |
Either "x" or "y", defining the direction of observed data. |
lloqOnBothAxes |
A boolean; if |
yDisplayAsAbsolute |
A boolean that defines the direction of comparison lines. |
A ggplot object representing the plotted data.
Other plot functions:
plotBoxWhisker(),
plotForest(),
plotHistogram(),
plotPredVsObs(),
plotQQ(),
plotRangeDistribution(),
plotRatioVsCov(),
plotResVsCov(),
plotTimeProfile()
This function customizes the printing of ggplot objects with the class "ggWatermark" by adding a watermark.
## S3 method for class 'ggWatermark' print(x, ...)## S3 method for class 'ggWatermark' print(x, ...)
x |
A ggWatermark object created by |
... |
Additional arguments to be passed to the print method, allowing for further customization of the output. |
A ggplot object with a watermark drawn on it. The watermark is displayed according to the specified options.
Other watermark:
addWatermark(),
ggplotWithWatermark(),
plot.ggWatermark()
reset the default color map for discrete colors
resetDefaultColorMapDistinct(oldColorMaps)resetDefaultColorMapDistinct(oldColorMaps)
oldColorMaps |
list of color maps previously set |
Other setDefault functions:
colorMaps,
getDefaultGeomAttributes(),
getDefaultOptions(),
getOspsuite.plots.option(),
resetDefaultTheme(),
resetDefaults(),
setDefaultColorMapDistinct(),
setDefaultTheme(),
setDefaults(),
setOspsuite.plots.option()
restore to previously stored settings
resetDefaults(oldDefaults)resetDefaults(oldDefaults)
oldDefaults |
|
Other setDefault functions:
colorMaps,
getDefaultGeomAttributes(),
getDefaultOptions(),
getOspsuite.plots.option(),
resetDefaultColorMapDistinct(),
resetDefaultTheme(),
setDefaultColorMapDistinct(),
setDefaultTheme(),
setDefaults(),
setOspsuite.plots.option()
wrapper for ggplot2::theme_set(oldTheme)
resetDefaultTheme(oldTheme)resetDefaultTheme(oldTheme)
oldTheme |
theme to set |
Other setDefault functions:
colorMaps,
getDefaultGeomAttributes(),
getDefaultOptions(),
getOspsuite.plots.option(),
resetDefaultColorMapDistinct(),
resetDefaults(),
setDefaultColorMapDistinct(),
setDefaultTheme(),
setDefaults(),
setOspsuite.plots.option()
Discrete shape scale that automatically assigns shapes from
ospShapeNames in order based on the number of factor levels.
Equivalent to ggplot2::scale_shape().
If there are more levels than available shapes, shapes are recycled and a warning is issued.
scale_shape_osp(...)scale_shape_osp(...)
... |
Passed to |
A ggplot2 scale that can be added to a plot.
Other shapes:
Shapes,
ospShapeNames,
scale_shape_osp_identity(),
scale_shape_osp_manual()
library(ggplot2) df <- data.frame(x = 1:3, y = 1:3, group = c("A", "B", "C")) ggplot(df, aes(x, y, shape = group)) + geom_point_osp(size = 4) + scale_shape_osp()library(ggplot2) df <- data.frame(x = 1:3, y = 1:3, group = c("A", "B", "C")) ggplot(df, aes(x, y, shape = group)) + geom_point_osp(size = 4) + scale_shape_osp()
Identity scale for when data already contains OSP shape names.
Use this when your shape column contains values from ospShapeNames
directly (e.g., "circle", "diamond", "star").
Equivalent to ggplot2::scale_shape_identity().
scale_shape_osp_identity(guide = "none", ...)scale_shape_osp_identity(guide = "none", ...)
guide |
Guide for the legend. Use |
... |
Passed to |
A ggplot2 scale that can be added to a plot.
Other shapes:
Shapes,
ospShapeNames,
scale_shape_osp(),
scale_shape_osp_manual()
library(ggplot2) df <- data.frame(x = 1:3, y = 1:3, shape = c("circle", "diamond", "star")) ggplot(df, aes(x, y, shape = shape)) + geom_point_osp(size = 4) + scale_shape_osp_identity(guide = "legend")library(ggplot2) df <- data.frame(x = 1:3, y = 1:3, shape = c("circle", "diamond", "star")) ggplot(df, aes(x, y, shape = shape)) + geom_point_osp(size = 4) + scale_shape_osp_identity(guide = "legend")
Manual shape scale for explicit mapping of factor levels to OSP shape names.
Equivalent to ggplot2::scale_shape_manual().
scale_shape_osp_manual(values, ...)scale_shape_osp_manual(values, ...)
values |
Named character vector. Names are factor levels;
values are entries from |
... |
Passed to |
A ggplot2 scale that can be added to a plot.
Other shapes:
Shapes,
ospShapeNames,
scale_shape_osp(),
scale_shape_osp_identity()
library(ggplot2) df <- data.frame(x = 1:3, y = 1:3, group = c("A", "B", "C")) ggplot(df, aes(x, y, shape = group)) + geom_point_osp(size = 4) + scale_shape_osp_manual(values = c(A = "circle", B = "diamond", C = "star"))library(ggplot2) df <- data.frame(x = 1:3, y = 1:3, group = c("A", "B", "C")) ggplot(df, aes(x, y, shape = group)) + geom_point_osp(size = 4) + scale_shape_osp_manual(values = c(A = "circle", B = "diamond", C = "star"))
Sets default color mappings for discrete color and fill aesthetics in ggplot2. Each color map should be a vector of valid color values (hex codes, color names, etc.).
setDefaultColorMapDistinct(colorMapList = NULL)setDefaultColorMapDistinct(colorMapList = NULL)
colorMapList |
list of color-maps to be set |
list with color-maps previously set
Other setDefault functions:
colorMaps,
getDefaultGeomAttributes(),
getDefaultOptions(),
getOspsuite.plots.option(),
resetDefaultColorMapDistinct(),
resetDefaultTheme(),
resetDefaults(),
setDefaultTheme(),
setDefaults(),
setOspsuite.plots.option()
## Not run: # Set custom color maps customColors <- list( c("#FF0000", "#00FF00", "#0000FF"), # RGB colors c("red", "green", "blue") # Named colors ) oldColors <- setDefaultColorMapDistinct(customColors) # Use default OSP color maps setDefaultColorMapDistinct() # Reset to previous colors resetDefaultColorMapDistinct(oldColors) ## End(Not run)## Not run: # Set custom color maps customColors <- list( c("#FF0000", "#00FF00", "#0000FF"), # RGB colors c("red", "green", "blue") # Named colors ) oldColors <- setDefaultColorMapDistinct(customColors) # Use default OSP color maps setDefaultColorMapDistinct() # Reset to previous colors resetDefaultColorMapDistinct(oldColors) ## End(Not run)
should be started at the beginning at each workflow
setDefaults(defaultOptions = list(), colorMapList = NULL)setDefaults(defaultOptions = list(), colorMapList = NULL)
defaultOptions |
list of options |
colorMapList |
list of color maps |
for detailed information see
vignette("ospsuite.plots", package = "ospsuite.plots")
list of old settings which can be used to reset defaults with resetDefaults()
Other setDefault functions:
colorMaps,
getDefaultGeomAttributes(),
getDefaultOptions(),
getOspsuite.plots.option(),
resetDefaultColorMapDistinct(),
resetDefaultTheme(),
resetDefaults(),
setDefaultColorMapDistinct(),
setDefaultTheme(),
setOspsuite.plots.option()
set properties of the default theme for OSPSuite plots. This function applies a custom theme based on theme_bw() with OSPSuite-specific styling.
setDefaultTheme()setDefaultTheme()
invisibly return the previous theme so you can easily save it, then later restore it.
Other setDefault functions:
colorMaps,
getDefaultGeomAttributes(),
getDefaultOptions(),
getOspsuite.plots.option(),
resetDefaultColorMapDistinct(),
resetDefaultTheme(),
resetDefaults(),
setDefaultColorMapDistinct(),
setDefaults(),
setOspsuite.plots.option()
## Not run: oldTheme <- setDefaultTheme() # Create a plot with the new theme p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() print(p) # Restore previous theme resetDefaultTheme(oldTheme) ## End(Not run)## Not run: oldTheme <- setDefaultTheme() # Create a plot with the new theme p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() print(p) # Restore previous theme resetDefaultTheme(oldTheme) ## End(Not run)
Set OSPSuite plots option with a given key and value.
setOspsuite.plots.option(optionKey, value)setOspsuite.plots.option(optionKey, value)
optionKey |
The key for the option. |
value |
The value for the option. |
Other setDefault functions:
colorMaps,
getDefaultGeomAttributes(),
getDefaultOptions(),
getOspsuite.plots.option(),
resetDefaultColorMapDistinct(),
resetDefaultTheme(),
resetDefaults(),
setDefaultColorMapDistinct(),
setDefaultTheme(),
setDefaults()
## Not run: setOspsuite.plots.option(optionKey = OptionKeys$watermarkEnabled, value = TRUE) ## End(Not run)## Not run: setOspsuite.plots.option(optionKey = OptionKeys$watermarkEnabled, value = TRUE) ## End(Not run)
Named list of OSP shape names for backward compatibility.
Use Shapes$circle to get the shape name "circle".
ShapesShapes
Other shapes:
ospShapeNames,
scale_shape_osp(),
scale_shape_osp_identity(),
scale_shape_osp_manual()
A stat_qq that uses OSP shapes via GeomPointOsp instead of standard
geom_point. This ensures QQ plots have visual consistency with other
OSP plots.
Unlike ggplot2::stat_qq(), this function does not expose a geom parameter
as it always uses GeomPointOsp for rendering.
stat_qq_osp( mapping = NULL, data = NULL, position = "identity", ..., distribution = stats::qnorm, dparams = list(), na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )stat_qq_osp( mapping = NULL, data = NULL, position = "identity", ..., distribution = stats::qnorm, dparams = list(), na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
distribution |
Distribution function to use, if x not specified |
dparams |
Additional parameters passed on to |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
A ggplot2 layer that can be added to a plot.
Other layers:
GeomErrorbarOsp,
GeomPointOsp,
geom_errorbar_osp(),
geom_point_osp()
adds break function with fixed width for breaks depending on unit:
updateScaleArgumentsForTimeUnit(scaleArgs, dimension, unit)updateScaleArgumentsForTimeUnit(scaleArgs, dimension, unit)
scaleArgs |
list of arguments for scale to be updated, passed to scale_x_continuous or scale_x_log10 |
dimension |
dimension of axis, if not 'time' list will not be updated |
unit |
A named list of information about the |
s: width = 15,
min: width = 15,
h: width = 6,
day(s): width = 7
week(s): width = 4
month(s): width = 6
The function uses the following logic to determine the breaks:
If the range of time values is relatively small (i.e., less than twice the width of the breaks), it will use a default set of extended breaks.
If the range of time values is larger, the function will check if it is appropriate to use wider breaks. Specifically, it will continue to double the width until it finds a width that is suitable, ensuring that 10 times the width is still less than the total range of time values. This means that the breaks will be spaced far enough apart to be meaningful without overcrowding the axis, providing clarity in the visualization.
update list of arguments for scale
xScaleArgs <- list(limits = c(0, 24)) xScaleArgs <- updateScaleArgumentsForTimeUnit( scaleArgs = xScaleArgs, dimension = "time", unit = "h" ) addXScale(plotObject = ggplot(), xScale = "linear", xScaleArgs = xScaleArgs)xScaleArgs <- list(limits = c(0, 24)) xScaleArgs <- updateScaleArgumentsForTimeUnit( scaleArgs = xScaleArgs, dimension = "time", unit = "h" ) addXScale(plotObject = ggplot(), xScale = "linear", xScaleArgs = xScaleArgs)