From 90d2734e9da2e843dab9152b498628d7e0703527 Mon Sep 17 00:00:00 2001 From: Pierre Chelle <45343665+pchelle@users.noreply.github.com> Date: Tue, 14 Jun 2022 04:25:19 -0400 Subject: [PATCH] Fixes #304 add enum helper for ticklabels (#305) * Fixes #304 add enum helper for ticklabels * Fix typo in Pi label mapping * Fix typo in example * If ticklabels is of type expression, numeric or function use it as is If expression or function isIncluded throw an error so the assertion is necessary before isIncluded * style and document Co-authored-by: Indrajeet Patil --- NAMESPACE | 3 ++ NEWS.md | 1 + R/ddiratio-datamapping.R | 2 +- R/plot-ddiratio.R | 16 +++---- R/plot-obs-vs-pred.R | 17 ++++---- R/plot-pkratio.R | 12 +++--- R/plot-res-vs-pred.R | 20 ++++----- R/plotconfiguration-axis.R | 33 ++++++++++++++- R/utilities-axis.R | 73 ++++++++++++++++++++++++++++++++ R/utilities-enums.R | 8 ++++ man/AestheticProperties.Rd | 1 + man/Alignments.Rd | 1 + man/ExportFormats.Rd | 1 + man/ExportUnits.Rd | 1 + man/FontFaces.Rd | 1 + man/HorizontalJustification.Rd | 1 + man/LegendPositions.Rd | 1 + man/Linetypes.Rd | 1 + man/PlotAnnotationTextSize.Rd | 1 + man/Scaling.Rd | 1 + man/Shapes.Rd | 1 + man/TagPositions.Rd | 1 + man/TickLabelTransforms.Rd | 34 +++++++++++++++ man/VerticalJustification.Rd | 1 + man/createPlotTickLabels.Rd | 19 +++++++++ man/getGreekTickLabels.Rd | 21 +++++++++ man/getPiTickLabels.Rd | 21 +++++++++ man/plotDDIRatio.Rd | 10 ++--- man/plotObsVsPred.Rd | 13 +++--- man/plotPKRatio.Rd | 6 +-- man/plotResVsTime.Rd | 6 +-- man/tlfStatFunctions.Rd | 1 + vignettes/plot-configuration.Rmd | 2 +- 33 files changed, 278 insertions(+), 53 deletions(-) create mode 100644 man/TickLabelTransforms.Rd create mode 100644 man/createPlotTickLabels.Rd create mode 100644 man/getGreekTickLabels.Rd create mode 100644 man/getPiTickLabels.Rd diff --git a/NAMESPACE b/NAMESPACE index af685fd0..574c2fab 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -80,6 +80,7 @@ export(ThemeAestheticSelections) export(ThemeBackground) export(ThemeFont) export(ThemePlotConfigurations) +export(TickLabelTransforms) export(TimeProfileDataMapping) export(TimeProfilePlotConfiguration) export(TornadoDataMapping) @@ -100,6 +101,7 @@ export(exportPlot) export(exportPlotConfigurationCode) export(getBoxWhiskerMeasure) export(getDefaultCaptions) +export(getGreekTickLabels) export(getGuestValues) export(getGuestValuesFromDataMapping) export(getLabelWithUnit) @@ -109,6 +111,7 @@ export(getLinesFromFoldDistance) export(getLnTickLabels) export(getLogTickLabels) export(getPKRatioMeasure) +export(getPiTickLabels) export(getSqrtTickLabels) export(initializePlot) export(loadThemeFromJson) diff --git a/NEWS.md b/NEWS.md index 9d22620a..f9e8a516 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,7 @@ - `HorizontalJustification` (horizontal justifications for plot annotation text) (#293) - `VerticalJustification` (vertical justifications for plot annotation text) (#293) - `PlotAnnotationTextSize` (default text sizes for plot annotations) (#293) + - `TickLabelTransforms` (predefined tick labeling) (#304) ## Minor improvements and bug fixes diff --git a/R/ddiratio-datamapping.R b/R/ddiratio-datamapping.R index 8c004725..62565059 100644 --- a/R/ddiratio-datamapping.R +++ b/R/ddiratio-datamapping.R @@ -31,7 +31,7 @@ DDIRatioDataMapping <- R6::R6Class( validateIsNumeric(minRange) validateIsOfLength(minRange, 2) validateIsLogical(residualsVsObserved) - + self$lines <- lines self$minRange <- minRange self$deltaGuest <- deltaGuest diff --git a/R/plot-ddiratio.R b/R/plot-ddiratio.R index d96d2f0c..2f448aa0 100644 --- a/R/plot-ddiratio.R +++ b/R/plot-ddiratio.R @@ -24,14 +24,14 @@ #' ddiData <- data.frame(x = c(1, 2, 1, 2, 3), y = c(5, 0.2, 2, 3, 4)) #' #' plotDDIRatio(data = ddiData, dataMapping = DDIRatioDataMapping$new(x = "x", y = "y")) -#' +#' #' # Produce DDI Ratio plot with user-defined horizontal lines #' plotDDIRatio( -#' data = ddiData, -#' dataMapping = DDIRatioDataMapping$new(x = "x", y = "y"), -#' foldDistance = c(1, 10), -#' deltaGuest = 1.25, -#' residualsVsObserved = TRUE +#' data = ddiData, +#' dataMapping = DDIRatioDataMapping$new(x = "x", y = "y"), +#' foldDistance = c(1, 10), +#' deltaGuest = 1.25, +#' residualsVsObserved = TRUE #' ) #' plotDDIRatio <- function(data, @@ -53,13 +53,13 @@ plotDDIRatio <- function(data, dataMapping$residualsVsObserved <- residualsVsObserved %||% dataMapping$residualsVsObserved dataMapping$deltaGuest <- deltaGuest %||% dataMapping$deltaGuest - + lineOrientation <- "diagonal" if (dataMapping$residualsVsObserved) { lineOrientation <- "ddiHorizontal" } # Include diagonal or horizontal lines depending on the plot type - if(!isEmpty(foldDistance)){ + if (!isEmpty(foldDistance)) { dataMapping$lines <- getLinesFromFoldDistance(foldDistance) } for (lineIndex in seq_along(dataMapping$lines)) { diff --git a/R/plot-obs-vs-pred.R b/R/plot-obs-vs-pred.R index e3942ddc..2a41a0ea 100644 --- a/R/plot-obs-vs-pred.R +++ b/R/plot-obs-vs-pred.R @@ -33,14 +33,15 @@ #' #' # Produce Obs vs Pred plot with user-defined fold distance lines #' plotObsVsPred( -#' data = obsVsPredData, -#' dataMapping = ObsVsPredDataMapping$new(x = "x", y = "y"), -#' plotConfiguration = ObsVsPredPlotConfiguration$new( -#' xScale = Scaling$log, xLimits = c(0.05, 50), -#' yScale = Scaling$log, yLimits = c(0.05, 50)), -#' foldDistance = c(1, 10) +#' data = obsVsPredData, +#' dataMapping = ObsVsPredDataMapping$new(x = "x", y = "y"), +#' plotConfiguration = ObsVsPredPlotConfiguration$new( +#' xScale = Scaling$log, xLimits = c(0.05, 50), +#' yScale = Scaling$log, yLimits = c(0.05, 50) +#' ), +#' foldDistance = c(1, 10) #' ) -#' +#' plotObsVsPred <- function(data, metaData = NULL, dataMapping = NULL, @@ -58,7 +59,7 @@ plotObsVsPred <- function(data, plotObject <- plotObject %||% initializePlot(plotConfiguration) # Add diagonal lines with offset defined in lines of dataMapping - if(!isEmpty(foldDistance)){ + if (!isEmpty(foldDistance)) { dataMapping$lines <- getLinesFromFoldDistance(foldDistance) } for (lineIndex in seq_along(dataMapping$lines)) { diff --git a/R/plot-pkratio.R b/R/plot-pkratio.R index 5cbb407b..b1518e45 100644 --- a/R/plot-pkratio.R +++ b/R/plot-pkratio.R @@ -21,12 +21,12 @@ #' pkData <- data.frame(x = c(1, 2, 1, 2, 3), y = c(5, 0.2, 2, 3, 4)) #' #' plotPKRatio(data = pkData, dataMapping = PKRatioDataMapping$new(x = "x", y = "y")) -#' +#' #' # Produce PK Ratio plot with user-defined horizontal lines #' plotPKRatio( -#' data = pkData, -#' dataMapping = PKRatioDataMapping$new(x = "x", y = "y"), -#' foldDistance = c(1, 10) +#' data = pkData, +#' dataMapping = PKRatioDataMapping$new(x = "x", y = "y"), +#' foldDistance = c(1, 10) #' ) #' plotPKRatio <- function(data, @@ -41,9 +41,9 @@ plotPKRatio <- function(data, mapLabels <- getAesStringMapping(dataMapping) plotObject <- plotObject %||% initializePlot(plotConfiguration) - + # Include horizontal lines - if(!isEmpty(foldDistance)){ + if (!isEmpty(foldDistance)) { dataMapping$lines <- getLinesFromFoldDistance(foldDistance) } for (lineIndex in seq_along(dataMapping$lines)) { diff --git a/R/plot-res-vs-pred.R b/R/plot-res-vs-pred.R index d04fb1e5..1ad9ddae 100644 --- a/R/plot-res-vs-pred.R +++ b/R/plot-res-vs-pred.R @@ -3,9 +3,9 @@ #' Producing residuals vs predicted plots #' #' @inheritParams plotObsVsPred -#' @param dataMapping +#' @param dataMapping #' A `ResVsPredDataMapping` object mapping `x`, `y` and aesthetic groups to their variable names of `data`. -#' @param plotConfiguration +#' @param plotConfiguration #' An optional `ResVsPredConfiguration` object defining labels, grid, background and watermark. #' @return A `ggplot` object #' @@ -94,24 +94,24 @@ plotResVsPred <- function(data, #' Producing residuals vs time plots #' #' @inheritParams plotObsVsPred -#' @param dataMapping +#' @param dataMapping #' A `ResVsTimeDataMapping` object mapping `x`, `y` and aesthetic groups to their variable names of `data`. -#' @param plotConfiguration +#' @param plotConfiguration #' An optional `ResVsTimeConfiguration` object defining labels, grid, background and watermark. #' @return A `ggplot` object #' #' @export #' @family molecule plots -#' @examples +#' @examples #' # Produce Obs vs Pred plot #' resVsTimeData <- data.frame(x = c(1, 2, 1, 2, 3), y = c(5, 0.2, 2, 3, 4)) -#' +#' #' plotResVsTime(data = resVsTimeData, dataMapping = ResVsTimeDataMapping$new(x = "x", y = "y")) -#' +#' #' # Produce Res vs Time plot with linear regression #' plotResVsTime( -#' data = resVsTimeData, -#' dataMapping = ResVsTimeDataMapping$new(x = "x", y = "y"), -#' smoother = "lm" +#' data = resVsTimeData, +#' dataMapping = ResVsTimeDataMapping$new(x = "x", y = "y"), +#' smoother = "lm" #' ) plotResVsTime <- plotResVsPred diff --git a/R/plotconfiguration-axis.R b/R/plotconfiguration-axis.R index 07873041..c5dd1f7b 100644 --- a/R/plotconfiguration-axis.R +++ b/R/plotconfiguration-axis.R @@ -38,6 +38,35 @@ createPlotTicks <- function(ticks) { return(ticks) } +#' @title createPlotTickLabels +#' @description Translate ticks and ticklabels into a value directly usable by `ggplot2` +#' to give more flexibilty in the next functions +#' @param ticklabels character, numeric or function defining the ticks +#' @return name of the `ggplot2` scale +#' @keywords internal +createPlotTickLabels <- function(ticklabels) { + if (isEmpty(ticklabels)) { + return(waiver()) + } + if (isOfType(ticklabels, c("numeric", "function", "expression"))) { + return(ticklabels) + } + if (isIncluded(ticklabels, TickLabelTransforms)) { + transformedLabels <- switch(ticklabels, + "default" = waiver(), + "none" = NULL, + "identity" = identity, + "log" = getLogTickLabels, + "ln" = getLnTickLabels, + "sqrt" = getSqrtTickLabels, + "greek" = getGreekTickLabels, + "pi" = getPiTickLabels + ) + return(transformedLabels) + } + return(ticklabels) +} + #' @title AxisConfiguration #' @description R6 class defining the configuration of axis #' @export @@ -69,7 +98,7 @@ AxisConfiguration <- R6::R6Class( scale <- scale %||% Scaling$lin private$.scale <- createPlotScale(scale) private$.ticks <- createPlotTicks(ticks) - private$.ticklabels <- createPlotTicks(ticklabels) + private$.ticklabels <- createPlotTickLabels(ticklabels) private$.expand <- expand # Default axis font will use theme @@ -176,7 +205,7 @@ AxisConfiguration <- R6::R6Class( if (missing(value)) { return(private$.ticklabels) } - private$.ticklabels <- createPlotTicks(value) + private$.ticklabels <- createPlotTickLabels(value) return(invisible()) }, #' @field font `Font` object defining the font of the ticklabels diff --git a/R/utilities-axis.R b/R/utilities-axis.R index 15834e35..872208d6 100644 --- a/R/utilities-axis.R +++ b/R/utilities-axis.R @@ -142,3 +142,76 @@ getSqrtTickLabels <- function(ticks) { sqrtValues <- ticks^2 return(parse(text = paste("sqrt(", sqrtValues, ")", sep = ""))) } + +#' @title getGreekTickLabels +#' @description Get ticklabels expressions for discrete scale plots with greek letters +#' @param ticks numeric values of the ticks +#' @return Expressions to use in `ticklabels` input parameter of `setXAxis` and `setYAxis` functions +#' @examples +#' ticks <- c(1, 5, 10, 50, 100, 500) +#' getGreekTickLabels(ticks) +#' @export +getGreekTickLabels <- function(ticks) { + # alpha starts at converted integer 945 + if (is.numeric(ticks)) { + return(sapply(ticks, function(tick) { + intToUtf8(tick + 944) + })) + } + tickLabels <- sapply(1:length(ticks), function(tick) { + intToUtf8(tick + 944) + }) + return(tickLabels) +} + +#' @title getPiTickLabels +#' @description Get ticklabels expressions for plots with values as ratios of Pi +#' @param ticks numeric values of the ticks +#' @return Expressions to use in `ticklabels` input parameter of `setXAxis` and `setYAxis` functions +#' @examples +#' ticks <- seq(0, 2 * pi, pi / 2) +#' getPiTickLabels(ticks) +#' @export +getPiTickLabels <- function(ticks) { + # Get fractions of pi from ticks + roundPi <- as.character(ticks %/% pi) + # Remove 1 and -1 from expression + roundPi[roundPi == "1"] <- "" + roundPi[roundPi == "-1"] <- "-" + # Flag when 0 to remove pi from label + roundPi[roundPi == "0"] <- "x" + + roundPi <- paste(roundPi, "\u03C0", sep = "") + roundPi[grepl("x", roundPi)] <- "" + + # Round to 3 digits to get fraction values + # If fraction is recognized, used fraction format + decPi <- round((ticks %% pi) / pi, 3) + decPi <- sapply(decPi, function(piFraction) { + if (piFraction == 0) { + return("") + } + if (piFraction == 0.167) { + return(" + \u03C0/6") + } + if (piFraction == 0.25) { + return(" + \u03C0/4") + } + if (piFraction == 0.333) { + return(" + \u03C0/3") + } + if (piFraction == 0.5) { + return(" + \u03C0/2") + } + if (piFraction == 0.667) { + return(" + 2\u03C0/3") + } + if (piFraction == 0.833) { + return(" + 5\u03C0/6") + } + return(paste0("+", piFraction, "\u03C0")) + }) + piLabels <- paste(roundPi, decPi, sep = "") + piLabels[piLabels == ""] <- "0" + return(piLabels) +} diff --git a/R/utilities-enums.R b/R/utilities-enums.R index f0a081ca..6846008e 100644 --- a/R/utilities-enums.R +++ b/R/utilities-enums.R @@ -320,3 +320,11 @@ ExportUnits <- enum(c("cm", "in", "mm", "px")) #' List of all available formats to export a ggplot object #' @family enum helpers ExportFormats <- enum(c("png", "pdf", "eps", "ps", "tex", "jpeg", "tiff", "bmp", "svg", "wmf")) + +#' @title TickLabelTransforms +#' @import ospsuite.utils +#' @export +#' @description +#' List of all available tick label transformation names +#' @family enum helpers +TickLabelTransforms <- enum(c("none", "default", "identity", "log", "ln", "sqrt", "greek", "pi")) diff --git a/man/AestheticProperties.Rd b/man/AestheticProperties.Rd index 5eaa3adc..67b3a454 100644 --- a/man/AestheticProperties.Rd +++ b/man/AestheticProperties.Rd @@ -26,6 +26,7 @@ Other enum helpers: \code{\link{Scaling}}, \code{\link{Shapes}}, \code{\link{TagPositions}}, +\code{\link{TickLabelTransforms}}, \code{\link{VerticalJustification}}, \code{\link{tlfStatFunctions}} } diff --git a/man/Alignments.Rd b/man/Alignments.Rd index ba85dda5..266ad2d2 100644 --- a/man/Alignments.Rd +++ b/man/Alignments.Rd @@ -26,6 +26,7 @@ Other enum helpers: \code{\link{Scaling}}, \code{\link{Shapes}}, \code{\link{TagPositions}}, +\code{\link{TickLabelTransforms}}, \code{\link{VerticalJustification}}, \code{\link{tlfStatFunctions}} } diff --git a/man/ExportFormats.Rd b/man/ExportFormats.Rd index 3925f8f1..ef95227b 100644 --- a/man/ExportFormats.Rd +++ b/man/ExportFormats.Rd @@ -26,6 +26,7 @@ Other enum helpers: \code{\link{Scaling}}, \code{\link{Shapes}}, \code{\link{TagPositions}}, +\code{\link{TickLabelTransforms}}, \code{\link{VerticalJustification}}, \code{\link{tlfStatFunctions}} } diff --git a/man/ExportUnits.Rd b/man/ExportUnits.Rd index b05382b8..2d3601ac 100644 --- a/man/ExportUnits.Rd +++ b/man/ExportUnits.Rd @@ -26,6 +26,7 @@ Other enum helpers: \code{\link{Scaling}}, \code{\link{Shapes}}, \code{\link{TagPositions}}, +\code{\link{TickLabelTransforms}}, \code{\link{VerticalJustification}}, \code{\link{tlfStatFunctions}} } diff --git a/man/FontFaces.Rd b/man/FontFaces.Rd index 6697a912..004b6ea6 100644 --- a/man/FontFaces.Rd +++ b/man/FontFaces.Rd @@ -26,6 +26,7 @@ Other enum helpers: \code{\link{Scaling}}, \code{\link{Shapes}}, \code{\link{TagPositions}}, +\code{\link{TickLabelTransforms}}, \code{\link{VerticalJustification}}, \code{\link{tlfStatFunctions}} } diff --git a/man/HorizontalJustification.Rd b/man/HorizontalJustification.Rd index c5e43855..6b400166 100644 --- a/man/HorizontalJustification.Rd +++ b/man/HorizontalJustification.Rd @@ -26,6 +26,7 @@ Other enum helpers: \code{\link{Scaling}}, \code{\link{Shapes}}, \code{\link{TagPositions}}, +\code{\link{TickLabelTransforms}}, \code{\link{VerticalJustification}}, \code{\link{tlfStatFunctions}} } diff --git a/man/LegendPositions.Rd b/man/LegendPositions.Rd index 5718ba67..be91460a 100644 --- a/man/LegendPositions.Rd +++ b/man/LegendPositions.Rd @@ -26,6 +26,7 @@ Other enum helpers: \code{\link{Scaling}}, \code{\link{Shapes}}, \code{\link{TagPositions}}, +\code{\link{TickLabelTransforms}}, \code{\link{VerticalJustification}}, \code{\link{tlfStatFunctions}} } diff --git a/man/Linetypes.Rd b/man/Linetypes.Rd index b9c6bc4a..c8971add 100644 --- a/man/Linetypes.Rd +++ b/man/Linetypes.Rd @@ -26,6 +26,7 @@ Other enum helpers: \code{\link{Scaling}}, \code{\link{Shapes}}, \code{\link{TagPositions}}, +\code{\link{TickLabelTransforms}}, \code{\link{VerticalJustification}}, \code{\link{tlfStatFunctions}} } diff --git a/man/PlotAnnotationTextSize.Rd b/man/PlotAnnotationTextSize.Rd index 614b5703..32a829ef 100644 --- a/man/PlotAnnotationTextSize.Rd +++ b/man/PlotAnnotationTextSize.Rd @@ -26,6 +26,7 @@ Other enum helpers: \code{\link{Scaling}}, \code{\link{Shapes}}, \code{\link{TagPositions}}, +\code{\link{TickLabelTransforms}}, \code{\link{VerticalJustification}}, \code{\link{tlfStatFunctions}} } diff --git a/man/Scaling.Rd b/man/Scaling.Rd index 6e54788d..fd958e46 100644 --- a/man/Scaling.Rd +++ b/man/Scaling.Rd @@ -55,6 +55,7 @@ Other enum helpers: \code{\link{PlotAnnotationTextSize}}, \code{\link{Shapes}}, \code{\link{TagPositions}}, +\code{\link{TickLabelTransforms}}, \code{\link{VerticalJustification}}, \code{\link{tlfStatFunctions}} } diff --git a/man/Shapes.Rd b/man/Shapes.Rd index a0b552d9..08cf9884 100644 --- a/man/Shapes.Rd +++ b/man/Shapes.Rd @@ -26,6 +26,7 @@ Other enum helpers: \code{\link{PlotAnnotationTextSize}}, \code{\link{Scaling}}, \code{\link{TagPositions}}, +\code{\link{TickLabelTransforms}}, \code{\link{VerticalJustification}}, \code{\link{tlfStatFunctions}} } diff --git a/man/TagPositions.Rd b/man/TagPositions.Rd index 8318eacf..b51cf8cd 100644 --- a/man/TagPositions.Rd +++ b/man/TagPositions.Rd @@ -26,6 +26,7 @@ Other enum helpers: \code{\link{PlotAnnotationTextSize}}, \code{\link{Scaling}}, \code{\link{Shapes}}, +\code{\link{TickLabelTransforms}}, \code{\link{VerticalJustification}}, \code{\link{tlfStatFunctions}} } diff --git a/man/TickLabelTransforms.Rd b/man/TickLabelTransforms.Rd new file mode 100644 index 00000000..ea215325 --- /dev/null +++ b/man/TickLabelTransforms.Rd @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utilities-enums.R +\docType{data} +\name{TickLabelTransforms} +\alias{TickLabelTransforms} +\title{TickLabelTransforms} +\format{ +An object of class \code{list} of length 8. +} +\usage{ +TickLabelTransforms +} +\description{ +List of all available tick label transformation names +} +\seealso{ +Other enum helpers: +\code{\link{AestheticProperties}}, +\code{\link{Alignments}}, +\code{\link{ExportFormats}}, +\code{\link{ExportUnits}}, +\code{\link{FontFaces}}, +\code{\link{HorizontalJustification}}, +\code{\link{LegendPositions}}, +\code{\link{Linetypes}}, +\code{\link{PlotAnnotationTextSize}}, +\code{\link{Scaling}}, +\code{\link{Shapes}}, +\code{\link{TagPositions}}, +\code{\link{VerticalJustification}}, +\code{\link{tlfStatFunctions}} +} +\concept{enum helpers} +\keyword{datasets} diff --git a/man/VerticalJustification.Rd b/man/VerticalJustification.Rd index e2931b5f..00b5d6bc 100644 --- a/man/VerticalJustification.Rd +++ b/man/VerticalJustification.Rd @@ -27,6 +27,7 @@ Other enum helpers: \code{\link{Scaling}}, \code{\link{Shapes}}, \code{\link{TagPositions}}, +\code{\link{TickLabelTransforms}}, \code{\link{tlfStatFunctions}} } \concept{enum helpers} diff --git a/man/createPlotTickLabels.Rd b/man/createPlotTickLabels.Rd new file mode 100644 index 00000000..b87eb457 --- /dev/null +++ b/man/createPlotTickLabels.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plotconfiguration-axis.R +\name{createPlotTickLabels} +\alias{createPlotTickLabels} +\title{createPlotTickLabels} +\usage{ +createPlotTickLabels(ticklabels) +} +\arguments{ +\item{ticklabels}{character, numeric or function defining the ticks} +} +\value{ +name of the \code{ggplot2} scale +} +\description{ +Translate ticks and ticklabels into a value directly usable by \code{ggplot2} +to give more flexibilty in the next functions +} +\keyword{internal} diff --git a/man/getGreekTickLabels.Rd b/man/getGreekTickLabels.Rd new file mode 100644 index 00000000..dbc5c74e --- /dev/null +++ b/man/getGreekTickLabels.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utilities-axis.R +\name{getGreekTickLabels} +\alias{getGreekTickLabels} +\title{getGreekTickLabels} +\usage{ +getGreekTickLabels(ticks) +} +\arguments{ +\item{ticks}{numeric values of the ticks} +} +\value{ +Expressions to use in \code{ticklabels} input parameter of \code{setXAxis} and \code{setYAxis} functions +} +\description{ +Get ticklabels expressions for discrete scale plots with greek letters +} +\examples{ +ticks <- c(1, 5, 10, 50, 100, 500) +getGreekTickLabels(ticks) +} diff --git a/man/getPiTickLabels.Rd b/man/getPiTickLabels.Rd new file mode 100644 index 00000000..5215afef --- /dev/null +++ b/man/getPiTickLabels.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utilities-axis.R +\name{getPiTickLabels} +\alias{getPiTickLabels} +\title{getPiTickLabels} +\usage{ +getPiTickLabels(ticks) +} +\arguments{ +\item{ticks}{numeric values of the ticks} +} +\value{ +Expressions to use in \code{ticklabels} input parameter of \code{setXAxis} and \code{setYAxis} functions +} +\description{ +Get ticklabels expressions for plots with values as ratios of Pi +} +\examples{ +ticks <- seq(0, 2 * pi, pi / 2) +getPiTickLabels(ticks) +} diff --git a/man/plotDDIRatio.Rd b/man/plotDDIRatio.Rd index bf0b3262..fe2183a2 100644 --- a/man/plotDDIRatio.Rd +++ b/man/plotDDIRatio.Rd @@ -48,11 +48,11 @@ plotDDIRatio(data = ddiData, dataMapping = DDIRatioDataMapping$new(x = "x", y = # Produce DDI Ratio plot with user-defined horizontal lines plotDDIRatio( -data = ddiData, -dataMapping = DDIRatioDataMapping$new(x = "x", y = "y"), -foldDistance = c(1, 10), -deltaGuest = 1.25, -residualsVsObserved = TRUE + data = ddiData, + dataMapping = DDIRatioDataMapping$new(x = "x", y = "y"), + foldDistance = c(1, 10), + deltaGuest = 1.25, + residualsVsObserved = TRUE ) } diff --git a/man/plotObsVsPred.Rd b/man/plotObsVsPred.Rd index 1b2e493e..5d6a76bf 100644 --- a/man/plotObsVsPred.Rd +++ b/man/plotObsVsPred.Rd @@ -55,12 +55,13 @@ plotObsVsPred( # Produce Obs vs Pred plot with user-defined fold distance lines plotObsVsPred( -data = obsVsPredData, -dataMapping = ObsVsPredDataMapping$new(x = "x", y = "y"), -plotConfiguration = ObsVsPredPlotConfiguration$new( -xScale = Scaling$log, xLimits = c(0.05, 50), -yScale = Scaling$log, yLimits = c(0.05, 50)), -foldDistance = c(1, 10) + data = obsVsPredData, + dataMapping = ObsVsPredDataMapping$new(x = "x", y = "y"), + plotConfiguration = ObsVsPredPlotConfiguration$new( + xScale = Scaling$log, xLimits = c(0.05, 50), + yScale = Scaling$log, yLimits = c(0.05, 50) + ), + foldDistance = c(1, 10) ) } diff --git a/man/plotPKRatio.Rd b/man/plotPKRatio.Rd index 2bc751e1..23172b9e 100644 --- a/man/plotPKRatio.Rd +++ b/man/plotPKRatio.Rd @@ -41,9 +41,9 @@ plotPKRatio(data = pkData, dataMapping = PKRatioDataMapping$new(x = "x", y = "y" # Produce PK Ratio plot with user-defined horizontal lines plotPKRatio( -data = pkData, -dataMapping = PKRatioDataMapping$new(x = "x", y = "y"), -foldDistance = c(1, 10) + data = pkData, + dataMapping = PKRatioDataMapping$new(x = "x", y = "y"), + foldDistance = c(1, 10) ) } diff --git a/man/plotResVsTime.Rd b/man/plotResVsTime.Rd index 20fd3edd..c69ca0ed 100644 --- a/man/plotResVsTime.Rd +++ b/man/plotResVsTime.Rd @@ -44,9 +44,9 @@ plotResVsTime(data = resVsTimeData, dataMapping = ResVsTimeDataMapping$new(x = " # Produce Res vs Time plot with linear regression plotResVsTime( -data = resVsTimeData, -dataMapping = ResVsTimeDataMapping$new(x = "x", y = "y"), -smoother = "lm" + data = resVsTimeData, + dataMapping = ResVsTimeDataMapping$new(x = "x", y = "y"), + smoother = "lm" ) } \seealso{ diff --git a/man/tlfStatFunctions.Rd b/man/tlfStatFunctions.Rd index 23cce8ad..922c6f3b 100644 --- a/man/tlfStatFunctions.Rd +++ b/man/tlfStatFunctions.Rd @@ -28,6 +28,7 @@ Other enum helpers: \code{\link{Scaling}}, \code{\link{Shapes}}, \code{\link{TagPositions}}, +\code{\link{TickLabelTransforms}}, \code{\link{VerticalJustification}} } \concept{enum helpers} diff --git a/vignettes/plot-configuration.Rmd b/vignettes/plot-configuration.Rmd index b94007b8..3bd4a97e 100644 --- a/vignettes/plot-configuration.Rmd +++ b/vignettes/plot-configuration.Rmd @@ -464,7 +464,7 @@ setXAxis(scatter1, limits = c(0.5, 20), scale = Scaling$sqrt) setXAxis(scatter1, limits = c(0, 6 * pi), ticks = seq(0, 6 * pi, pi), - ticklabels = c("0", "pi", paste0(seq(2, 6), "*pi")), + ticklabels = TickLabelTransforms$pi, font = Font$new(color = "dodgerblue") ) ```