Skip to content

Commit

Permalink
Merge pull request #521 from Open-Systems-Pharmacology/develop
Browse files Browse the repository at this point in the history
Release 1.5.170
  • Loading branch information
Yuri05 committed Sep 9, 2024
2 parents 1d3cde9 + 2257c8f commit bd595c7
Show file tree
Hide file tree
Showing 1,180 changed files with 3,167 additions and 123,575 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/update-dev-website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Update dev website
on:
push:
branches:
- develop

# The action needs permissions to update the branch
permissions:
contents: write

jobs:
update_dev_website:
uses: Open-Systems-Pharmacology/Workflows/.github/workflows/CreateGitHubPagesForR.yml@main
with:
pkgdown_mode: 'devel'
extra_r_packages: 'github::Open-Systems-Pharmacology/OSPSuite.RUtils'
17 changes: 17 additions & 0 deletions .github/workflows/update-release-website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Update release website
# The action is triggered only when update is push on main branch
on:
push:
branches:
- main

# The action needs permissions to update the branch
permissions:
contents: write

jobs:
update_release_website:
uses: Open-Systems-Pharmacology/Workflows/.github/workflows/CreateGitHubPagesForR.yml@main
with:
pkgdown_mode: 'release'
extra_r_packages: 'github::Open-Systems-Pharmacology/OSPSuite.RUtils'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
.Ruserdata
inst/doc
doc
docs
Meta
Rplots.pdf
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ Imports:
ospsuite.utils (>= 1.4.0),
patchwork,
ggtext,
stringr,
stringr (>= 1.5.0),
rlang,
lifecycle
Depends:
R (>= 3.6)
Encoding: UTF-8
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
Roxygen: list(markdown = TRUE)
Suggests:
cowplot,
Expand Down Expand Up @@ -122,5 +122,7 @@ Collate:
'utilities-mapping.R'
'utilities-molecule-plots.R'
'utilities-theme.R'
'utilities-tlf.R'
'utils.R'
'zzz.R'
Config/testthat/edition: 3
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,10 @@ export(getPiTickLabels)
export(getSameLimits)
export(getSqrtTickLabels)
export(getSymmetricLimits)
export(getTLFSettings)
export(initializePlot)
export(isBetween)
export(loadTLFSettings)
export(loadThemeFromJson)
export(plotBoxWhisker)
export(plotCumulativeTimeProfile)
Expand All @@ -149,8 +151,10 @@ export(plotResVsTime)
export(plotSimulatedTimeProfile)
export(plotTimeProfile)
export(plotTornado)
export(resetTLFSettingsToDefault)
export(runPlotMaker)
export(runThemeMaker)
export(saveTLFSettings)
export(saveThemeToJson)
export(setBackground)
export(setBackgroundPanelArea)
Expand Down Expand Up @@ -192,6 +196,7 @@ export(setXGrid)
export(setY2Axis)
export(setYAxis)
export(setYGrid)
export(tlfSettingsNames)
export(tlfStatFunctions)
export(updateExportDimensionsForLegend)
export(updateTimeProfileLegend)
Expand Down
8 changes: 6 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
- The `xLimits` and `yLimits` argument in `PlotConfiguration` are renamed `xAxisLimits` and `yAxisLimits`.
This will crop the axis limits but keep all the data to generate the plot (see `ggplot2::coord_cartesian`).
- New `xValuesLimits` and `yValuesLimits` argument in `PlotConfiguration` to filter the **data** used to generate the plot. (see `ggplot2::scale_continuous_x`).
- Groups names are now wraped on several lines if their number of characters is longer than 60.
- Plots and plotGrids labels (titles, subtitles, caption and axis labels) are now automatically fitting plot's width and wraped on several lines if too long.
- Groups names are now wrapped on several lines if their number of characters is longer than 60.
- Plots and plotGrids labels (titles, subtitles, caption and axis labels) are now automatically fitting plot's width and wrapped on several lines if too long.
- Plot labels texts are now sanitized from any unsupported characters.
- Plot labels now have margin around them. This can be configured in `Label`
objects.

## Minor improvements and bug fixes

- Error bars cap sized are now drawn only if the error bars are displayed.
- Fix a bug where error bars caps were wrongly displayed (#1410)[https://github.com/Open-Systems-Pharmacology/OSPSuite-R/issues/1410]

# tlf 1.5.0

Expand Down
14 changes: 7 additions & 7 deletions R/atom-plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ addScatter <- function(data = NULL,
x = .data[[mapLabels$x]],
y = .data[[mapLabels$y]],
linetype = .data$legendLabels,
color = .data$legendLabels,
size = .data$legendLabels
color = .data$legendLabels
),
linewidth = .getAestheticValues(n = 1, selectionKey = plotConfiguration$lines$size, aesthetic = "size"),
alpha = .getAestheticValues(n = 1, selectionKey = plotConfiguration$points$alpha, aesthetic = "alpha"),
show.legend = TRUE,
na.rm = TRUE
Expand Down Expand Up @@ -312,8 +312,8 @@ addLine <- function(data = NULL,
yintercept = .data[[mapLabels$y]],
linetype = .data$legendLabels,
color = .data$legendLabels,
size = .data$legendLabels
),
linewidth = .getAestheticValues(n = 1, selectionKey = plotConfiguration$lines$size, aesthetic = "size"),
alpha = .getAestheticValues(n = 1, selectionKey = plotConfiguration$lines$alpha, aesthetic = "alpha"),
show.legend = TRUE
) +
Expand All @@ -336,9 +336,9 @@ addLine <- function(data = NULL,
mapping = ggplot2::aes(
xintercept = .data[[mapLabels$x]],
linetype = .data$legendLabels,
color = .data$legendLabels,
size = .data$legendLabels
color = .data$legendLabels
),
linewidth = .getAestheticValues(n = 1, selectionKey = plotConfiguration$lines$size, aesthetic = "size"),
alpha = .getAestheticValues(n = 1, selectionKey = plotConfiguration$lines$alpha, aesthetic = "alpha"),
show.legend = TRUE
) +
Expand Down Expand Up @@ -378,8 +378,8 @@ addLine <- function(data = NULL,
y = .data[[mapLabels$y]],
linetype = .data$legendLabels,
color = .data$legendLabels,
size = .data$legendLabels
),
linewidth = .getAestheticValues(n = 1, selectionKey = plotConfiguration$lines$size, aesthetic = "size"),
alpha = .getAestheticValues(n = 1, selectionKey = plotConfiguration$lines$alpha, aesthetic = "alpha"),
show.legend = TRUE,
na.rm = TRUE
Expand Down Expand Up @@ -662,7 +662,7 @@ addErrorbar <- function(data = NULL,
color = .data[[mapLabels$color]],
group = .data[[mapLabels$color]]
),
size = .getAestheticValues(n = 1, selectionKey = plotConfiguration$errorbars$size, position = 0, aesthetic = "size"),
linewidth = .getAestheticValues(n = 1, selectionKey = plotConfiguration$errorbars$size, position = 0, aesthetic = "size"),
linetype = .getAestheticValues(n = 1, selectionKey = plotConfiguration$errorbars$linetype, aesthetic = "linetype"),
alpha = .getAestheticValues(n = 1, selectionKey = plotConfiguration$errorbars$alpha, aesthetic = "alpha"),
color = .getAestheticValues(n = 1, selectionKey = plotConfiguration$errorbars$color, aesthetic = "color"),
Expand Down
28 changes: 15 additions & 13 deletions R/error-checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@
#' @param values numeric values to be validated
#' @param nullAllowed logical allowing `NULL` as input
#' @keywords internal
.validateIsStrictlyPositive <- function(values, nullAllowed = FALSE){
.validateIsStrictlyPositive <- function(values, nullAllowed = FALSE) {
validateIsNumeric(values, nullAllowed = nullAllowed)
# all(NULL > 0) is true
# validateIsNumeric already took care of values = null but not allowed situation
if(all(values > 0)){
if (all(values > 0)) {
return(invisible())
}
stop(messages$errorValuesNotStrictlyPositive(values))
Expand All @@ -79,11 +79,11 @@
#'
#' @inheritParams isBetween
#' @keywords internal
.checkIsBetween <- function(x, left, right, strict = FALSE){
.checkIsBetween <- function(x, left, right, strict = FALSE) {
validateIsNumeric(x)
validateIsNumeric(left)
validateIsNumeric(right)
if(all(isBetween(x, left, right, strict))){
if (all(isBetween(x, left, right, strict))) {
return(invisible())
}
warning(messages$warningValuesNotWitinRange(x, left, right, strict))
Expand All @@ -97,17 +97,19 @@
#' @param availableAngles available angle for usage og `ggtext`
#' @import ospsuite.utils
#' @keywords internal
.checkIsInAvailableAngles <- function(angle, availableAngles = c(0,90,180,270)){
.checkIsInAvailableAngles <- function(angle, availableAngles = c(0, 90, 180, 270)) {
validateIsNumeric(angle)
newAngle <- tryCatch({
validateIsIncluded(angle, availableAngles)
return(angle)
},
error = function(e){
newAngle <- tryCatch(
{
validateIsIncluded(angle, availableAngles)
return(angle)
},
error = function(e) {
angleDifferences <- abs(angle - availableAngles)
closestAngle <- head(availableAngles[which(angleDifferences == min(angleDifferences))], 1)
warning(messages$warningAngleNotIncludedInAvailableAngles(angle, closestAngle))
return(closestAngle)
})
return(closestAngle)
}
)
return(newAngle)
}
}
3 changes: 2 additions & 1 deletion R/global-vars.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ utils::globalVariables(
"linetypeLength",
"newPlotObject",
"shape",
"size"
"size",
"newEnv"
),
package = "tlf",
add = FALSE
Expand Down
2 changes: 1 addition & 1 deletion R/plot-cumulative-time-profile.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ plotCumulativeTimeProfile <- function(data = NULL,
color = .data[[mapLabels$color]]
),
alpha = aestheticValues$alpha,
size = aestheticValues$size,
linewidth = aestheticValues$size,
linetype = aestheticValues$linetype,
# Cumulative componenent
position = ggplot2::position_stack(),
Expand Down
4 changes: 2 additions & 2 deletions R/plot-ddiratio.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ plotDDIRatio <- function(data,
color = aestheticValues$color,
linetype = aestheticValues$linetype,
alpha = aestheticValues$alpha,
size = aestheticValues$size
linewidth = aestheticValues$size
) +
ggplot2::geom_path(
data = guestData,
Expand All @@ -112,7 +112,7 @@ plotDDIRatio <- function(data,
color = aestheticValues$color,
linetype = aestheticValues$linetype,
alpha = aestheticValues$alpha,
size = aestheticValues$size
linewidth = aestheticValues$size
)

# 2- Error bars
Expand Down
2 changes: 1 addition & 1 deletion R/plot-histogram.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ plotHistogram <- function(data = NULL,
color = .data$legendLabels,
linetype = .data$legendLabels
),
size = aestheticValues$size,
linewidth = aestheticValues$size,
alpha = aestheticValues$alpha
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/plot-simulated-time-profile.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ plotSimulatedTimeProfile <- function(data = NULL,
color = .data[[mapLabels$color]],
linetype = .data[[mapLabels$linetype]]
),
size = aestheticValues$size,
linewidth = aestheticValues$size,
alpha = aestheticValues$alpha,
na.rm = TRUE,
show.legend = TRUE,
Expand Down
2 changes: 1 addition & 1 deletion R/plot-timeprofile.R
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ plotTimeProfile <- function(data = NULL,
color = .data[[mapLabels$color]],
linetype = .data[[mapLabels$linetype]]
),
size = aestheticValues$size,
linewidth = aestheticValues$size,
alpha = aestheticValues$alpha,
na.rm = TRUE,
show.legend = TRUE,
Expand Down
2 changes: 1 addition & 1 deletion R/plot-tornado.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ plotTornado <- function(data = NULL,
color = .data[[mapLabels$color]]
),
alpha = aestheticValues$alpha,
size = aestheticValues$size,
linewidth = aestheticValues$size,
linetype = aestheticValues$linetype,
position = ggplot2::position_dodge(width = plotConfiguration$dodge),
na.rm = TRUE
Expand Down
4 changes: 2 additions & 2 deletions R/plotconfiguration-background.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ BackgroundElement <- R6::R6Class(
ggplot2::element_rect(
fill = fill %||% self$fill,
colour = color %||% self$color,
size = size %||% as.numeric(self$size),
linewidth = size %||% as.numeric(self$size),
linetype = linetype %||% self$linetype
)
}
Expand All @@ -226,7 +226,7 @@ LineElement <- R6::R6Class(
createPlotElement = function(color = NULL, size = NULL, linetype = NULL) {
ggplot2::element_line(
colour = color %||% self$color,
size = size %||% as.numeric(self$size),
linewidth = size %||% as.numeric(self$size),
linetype = linetype %||% self$linetype
)
}
Expand Down
3 changes: 2 additions & 1 deletion R/plotconfiguration-export.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ ExportConfiguration <- R6::R6Class(
width = self$width,
height = self$height,
units = self$units,
dpi = self$dpi
dpi = self$dpi,
create.dir = TRUE
)
},
error = function(e) {
Expand Down
21 changes: 16 additions & 5 deletions R/plotconfiguration-legend.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,22 @@ LegendConfiguration <- R6::R6Class(
# Update legend position and alignment
legendPosition <- .createPlotLegendPosition(private$.position)

plotObject <- plotObject + ggplot2::theme(
legend.position = c(legendPosition$xPosition, legendPosition$yPosition),
legend.justification = c(legendPosition$xJustification, legendPosition$yJustification),
legend.direction = "vertical"
)

if (is.numeric(c(legendPosition$xPosition, legendPosition$yPosition))) {
plotObject <- plotObject + ggplot2::theme(
legend.position = "inside",
legend.position.inside = c(legendPosition$xPosition, legendPosition$yPosition),
legend.justification = c(legendPosition$xJustification, legendPosition$yJustification),
legend.direction = "vertical"
)
} else if (is.character(c(legendPosition$xPosition, legendPosition$yPosition))) {
plotObject <- plotObject + ggplot2::theme(
legend.position = c(legendPosition$xPosition, legendPosition$yPosition),
legend.justification = c(legendPosition$xJustification, legendPosition$yJustification),
legend.direction = "vertical"
)
}

# TO DO: update caption properties before returning plot
return(plotObject)
}
Expand Down
4 changes: 2 additions & 2 deletions R/timeprofile-plotconfiguration.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ TimeProfilePlotConfiguration <- R6::R6Class(

# On right axis, ggtext mirror angles. This is a workaround to get the
# correct angle
if (private$.labels$y2label$font$angle %% 360 == 180){
if (private$.labels$y2label$font$angle %% 360 == 180) {
private$.labels$y2label$font$angle <- 270
}
if (private$.labels$y2label$font$angle %% 360 == 270){
if (private$.labels$y2label$font$angle %% 360 == 270) {
private$.labels$y2label$font$angle <- 180
}

Expand Down
Loading

0 comments on commit bd595c7

Please sign in to comment.