Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to the PlotGridConfiguration class #293

Merged
merged 21 commits into from
May 25, 2022

Conversation

IndrajeetPatil
Copy link
Member

@IndrajeetPatil IndrajeetPatil commented May 24, 2022

@IndrajeetPatil IndrajeetPatil changed the title 274 print plotgridconfig Define a print method for PlotGridConfiguration class May 24, 2022
@IndrajeetPatil IndrajeetPatil requested a review from PavelBal May 24, 2022 09:13
@IndrajeetPatil
Copy link
Member Author

Print output:

library(tlf)

set.seed(123)
ls_plots <- list(
  # first plot
  plotBoxWhisker(mtcars,
    dataMapping = BoxWhiskerDataMapping$new(x = "am", y = "wt"), outliers = FALSE
  ),
  # second plot
  plotBoxWhisker(ToothGrowth,
    dataMapping = BoxWhiskerDataMapping$new(x = "supp", y = "len")
  )
)

plotGridObj <- PlotGridConfiguration$new(ls_plots)

plotGridObj$title <- "my combined plot"
plotGridObj$subtitle <- "something clever"
plotGridObj$caption <- "something dumb"
plotGridObj$nColumns <- 2L
plotGridObj$nRows <- 1L
plotGridObj$byRow <- TRUE
plotGridObj$tagLevels <- "A"
plotGridObj$tagPrefix <- "Plot ("
plotGridObj$tagSuffix <- ")"

plotGridObj
#> PlotGridConfiguration: 
#>    Plot grid annotations: 
#>      Title: my combined plot 
#>      Subtitle: something clever 
#>      Caption: something dumb 
#>    Plot grid arrangement: 
#>      Number of plots included: 2 
#>      Number of columns in the grid: 2 
#>      Number of rows in the grid: 1 
#>      Arranged in row-major order: TRUE 
#>    Individual plot tags: 
#>      Tag level format: A 
#>      Tag level prefix: Plot ( 
#>      Tag level suffix: ) 
#>      Tag level separator:

Created on 2022-05-24 by the reprex package (v2.0.1.9000)

@IndrajeetPatil IndrajeetPatil marked this pull request as draft May 24, 2022 10:36
@IndrajeetPatil

This comment was marked as outdated.

@IndrajeetPatil IndrajeetPatil changed the title Define a print method for PlotGridConfiguration class Improvements to the PlotGridConfiguration class May 24, 2022
- Add needed enums
- Update NEWS for the same
- Update docs
- Add test
- Update examples
@IndrajeetPatil
Copy link
Member Author

library(ggplot2)
library(tlf)

# plots to be arranged in a grid
set.seed(123)
ls_plots <- list(
  plotHistogram(x = rnorm(100)),
  plotHistogram(x = rnorm(100, mean = 3)),
  plotHistogram(x = rnorm(100, mean = 10))
)

# create an instance of plot configuration class
plotGridObj <- PlotGridConfiguration$new(plotList = ls_plots)

# specify further customizations for the plot grid
plotGridObj$title <- "my combined plot"
plotGridObj$subtitle <- "something clever"
plotGridObj$caption <- "my sources"
plotGridObj$nColumns <- 2L
plotGridObj$tagLevels <- "A"
plotGridObj$tagPrefix <- "Plot ("
plotGridObj$tagSuffix <- ")"
plotGridObj$tagColor <- "orange"
plotGridObj$tagSize <- 15
plotGridObj$tagAngle <- 45
plotGridObj$tagPosition <- TagPositions$top
plotGridObj$titleColor <- "darkgreen"
plotGridObj$subtitleColor <- "darkred"
plotGridObj$captionColor <- "blue"
plotGridObj$captionSize <- 12
plotGridObj$titleHorizontalJustification <- HorizontalJustification$middle
plotGridObj$subtitleHorizontalJustification <- HorizontalJustification$middle
plotGridObj$captionHorizontalJustification <- HorizontalJustification$middle

# plot the grid
plotGrid(plotGridObj)

Created on 2022-05-24 by the reprex package (v2.0.1.9000)

@codecov-commenter
Copy link

codecov-commenter commented May 24, 2022

Codecov Report

Merging #293 (783baba) into develop (fe1fb85) will increase coverage by 6.48%.
The diff coverage is 74.74%.

@@             Coverage Diff             @@
##           develop     #293      +/-   ##
===========================================
+ Coverage    57.79%   64.28%   +6.48%     
===========================================
  Files           51       51              
  Lines         2827     2878      +51     
===========================================
+ Hits          1634     1850     +216     
+ Misses        1193     1028     -165     
Impacted Files Coverage Δ
R/tlf-env.R 0.00% <0.00%> (ø)
R/utilities-axis.R 64.70% <64.70%> (ø)
R/plot-grid.R 80.51% <71.15%> (+49.75%) ⬆️
R/utilities-export.R 81.04% <81.04%> (ø)
R/font.R 86.95% <86.95%> (ø)
R/aggregation-input.R 90.69% <90.69%> (ø)
R/utilities-aesthetics.R 94.73% <94.73%> (ø)
R/plotconfiguration-background.R 87.14% <100.00%> (ø)
R/plotconfiguration-axis.R 88.57% <0.00%> (+5.00%) ⬆️
R/boxwhisker-plotconfiguration.R 100.00% <0.00%> (+62.50%) ⬆️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe1fb85...783baba. Read the comment docs.

@IndrajeetPatil IndrajeetPatil marked this pull request as ready for review May 24, 2022 12:58
@IndrajeetPatil IndrajeetPatil requested a review from Yuri05 May 24, 2022 13:11
Package: tlf
Type: Package
Title: TLF Library
Version: 1.4.0
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yuri05 Bumping the version. Is that okay?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes :)

@@ -12,10 +12,10 @@ install:
- git submodule update --init --recursive

environment:
app_version: "1.3"
app_version: "1.4"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yuri05 Same as DESCRIPTION

USE_RTOOLS: true
R_ARCH: x64
R_VERSION: "4.0.5"
R_VERSION: "4.1.0"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that visual regression tests can run on AppVeyor

@IndrajeetPatil IndrajeetPatil requested a review from pchelle May 24, 2022 13:12
R/plot-grid.R Outdated
title = NULL,
titleColor = "black",
titleSize = 14,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we have this (and other sizes below) as a constant somewhere in the tlf?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but I have created an enum for it now.

Comment on lines +2 to +15
# ****IMPORTANT**
#
# Do not move these enums to any other file!
#
# R6 class generators will create classes at build time. This means that if any
# of the enums are to be used inside these class environments, they need to be
# already available in the NAMESPACE when classes are being created. If not, you
# will get "object not found" error because R6 class generator can't find these
# enums in the NAMESPACE.
#
# This whole problem can be easily avoided by collating NAMESPACE alphabetically
# and including the enums in `aaa-` file which will be loaded before all other
# files and therefore all R6 class environments can find the needed enums since
# these classes will be defined in these other files.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pchelle Please make note of this. I have moved all enums to a single file now.

I need to some more research into this, but keeping them in a single file is a good solution at the moment.

@IndrajeetPatil
Copy link
Member Author

@Yuri05 I have made the changes you had asked. Let me know if you want me to change anything else.

@Yuri05
Copy link
Member

Yuri05 commented May 25, 2022

Let me know if you want me to change anything else.

Change the world :)
PR looks good, merging

@Yuri05 Yuri05 merged commit dda1020 into develop May 25, 2022
@Yuri05 Yuri05 deleted the 274_print_plotgridconfig branch May 25, 2022 14:31
msevestre pushed a commit that referenced this pull request Jun 24, 2022
* Fixes #280 background elements defined a priori (#284)

This allows to switch off grid at creation of plot configuration

* Fixes #281 Fixes #282 update vignettes (#290)

* Fixes #289 update news (#291)

* 273 na rm (#278)

* Fixes #273 NA are removed without producing warnings

* Fixes #272 set transparency for molecular plots

* Update line layer in scatter plots

* Fix typo

Co-authored-by: Indrajeet Patil <[email protected]>

* Fixes #288 create sections in reference page of doc website (#292)

* Fixes #288 create sections in reference page of doc website

* Remove duplicated last reference section

* Export configuration output folder (#287)

* Add `path` property to `ExportConfiguration`

* Added argument `path` to `ExportConfiguration`
Documentation generated with roxygen2

* Run styler

* Fix wrong assignment of `path` property

* adopt same gitattributes as other R repos in OSP (#295)

* whitespace changes due to new gitattributes

* Improvements to the `PlotGridConfiguration` class (#293)

* Bump package version; update NEWS

* Also update website for new package version

* rest

* Update appveyor.yml

* Add print method for plot grid config

Closes #274

* document

* better example

* better headers

* add more aesthetic parameters for plot grid config

- Add needed enums
- Update NEWS for the same
- Update docs
- Add test
- Update examples

* style

* caption position

* bump version

* Add PlotAnnotationTextSize

* move enums to plot grid file

* docs

* Update PlotGridConfiguration.Rd

* needed for vdiffr tests

* move all enums to their own file

* also add watermark size to the enum (#297)

* whitespace changes due to new gitattributes

* Use utilities from ospsuite.utils (#299)

To be considered once Open-Systems-Pharmacology/OSPSuite.RUtils#115 is merged.

* Add `collate` directive (#296)

* Fixes #301 Helper function to get lines from fold distance values (#302)

* Fixes #301 Helper function to get lines from fold distance values

* Update news, doc and style

* Update NEWS.md

* Update NEWS.md

Co-authored-by: Indrajeet Patil <[email protected]>

* 262 res vs pred (#270)

* Fixes #262 update documentation of plotResVsPred

* Fixes #262 res vs time functions are aliases of res vs pred functions

Include plotResVsTime, ResVsTimePlotConfiguration and ResVsTimeDataMapping

* res vs time classes derive from res vs pred

As a consequence, they are not equal and can have different theme properties

* re-document

Co-authored-by: Indrajeet Patil <[email protected]>

* 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 <[email protected]>

* Prepend internal function names with a dot (#307)

As per coding guidelines.

Update docs for these functions as well.

Closes #306

* 308 fold distance (#311)

* Fixes #313 Remove badges from Website-docu, update news (#314)

Co-authored-by: Yuri05 <[email protected]>

* Fixes #260 legend titles are updated and can be defined in themes (#315)

* Fixes #260 legend titles are updated and can be defined in themes

* Remove legend and legend title reset in boxplots

* Fixes #312 remove infinite values from plots (#316)

* fixes #318 Update website (#319)

Co-authored-by: Yuri05 <[email protected]>

* Fixes #320 Website: some images not displayed (#321)

Co-authored-by: Yuri05 <[email protected]>

* 320 attempt2 (#322)

* delete old docs folder

* Fixes #320 Website: some images not displayed

Co-authored-by: Yuri05 <[email protected]>

Co-authored-by: Pierre Chelle <[email protected]>
Co-authored-by: Indrajeet Patil <[email protected]>
Co-authored-by: Pavel Balazki <[email protected]>
Co-authored-by: Yuri05 <[email protected]>
Yuri05 pushed a commit to Yuri05/TLF-Library that referenced this pull request Jan 27, 2023
…acology#293)

* Bump package version; update NEWS

* Also update website for new package version

* rest

* Update appveyor.yml

* Add print method for plot grid config

Closes Open-Systems-Pharmacology#274

* document

* better example

* better headers

* add more aesthetic parameters for plot grid config

- Add needed enums
- Update NEWS for the same
- Update docs
- Add test
- Update examples

* style

* caption position

* bump version

* Add PlotAnnotationTextSize

* move enums to plot grid file

* docs

* Update PlotGridConfiguration.Rd

* needed for vdiffr tests

* move all enums to their own file
msevestre added a commit that referenced this pull request Jan 27, 2023
* Version 1.4.89 (#323)

* Fixes #280 background elements defined a priori (#284)

This allows to switch off grid at creation of plot configuration

* Fixes #281 Fixes #282 update vignettes (#290)

* Fixes #289 update news (#291)

* 273 na rm (#278)

* Fixes #273 NA are removed without producing warnings

* Fixes #272 set transparency for molecular plots

* Update line layer in scatter plots

* Fix typo

Co-authored-by: Indrajeet Patil <[email protected]>

* Fixes #288 create sections in reference page of doc website (#292)

* Fixes #288 create sections in reference page of doc website

* Remove duplicated last reference section

* Export configuration output folder (#287)

* Add `path` property to `ExportConfiguration`

* Added argument `path` to `ExportConfiguration`
Documentation generated with roxygen2

* Run styler

* Fix wrong assignment of `path` property

* adopt same gitattributes as other R repos in OSP (#295)

* whitespace changes due to new gitattributes

* Improvements to the `PlotGridConfiguration` class (#293)

* Bump package version; update NEWS

* Also update website for new package version

* rest

* Update appveyor.yml

* Add print method for plot grid config

Closes #274

* document

* better example

* better headers

* add more aesthetic parameters for plot grid config

- Add needed enums
- Update NEWS for the same
- Update docs
- Add test
- Update examples

* style

* caption position

* bump version

* Add PlotAnnotationTextSize

* move enums to plot grid file

* docs

* Update PlotGridConfiguration.Rd

* needed for vdiffr tests

* move all enums to their own file

* also add watermark size to the enum (#297)

* whitespace changes due to new gitattributes

* Use utilities from ospsuite.utils (#299)

To be considered once Open-Systems-Pharmacology/OSPSuite.RUtils#115 is merged.

* Add `collate` directive (#296)

* Fixes #301 Helper function to get lines from fold distance values (#302)

* Fixes #301 Helper function to get lines from fold distance values

* Update news, doc and style

* Update NEWS.md

* Update NEWS.md

Co-authored-by: Indrajeet Patil <[email protected]>

* 262 res vs pred (#270)

* Fixes #262 update documentation of plotResVsPred

* Fixes #262 res vs time functions are aliases of res vs pred functions

Include plotResVsTime, ResVsTimePlotConfiguration and ResVsTimeDataMapping

* res vs time classes derive from res vs pred

As a consequence, they are not equal and can have different theme properties

* re-document

Co-authored-by: Indrajeet Patil <[email protected]>

* 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 <[email protected]>

* Prepend internal function names with a dot (#307)

As per coding guidelines.

Update docs for these functions as well.

Closes #306

* 308 fold distance (#311)

* Fixes #313 Remove badges from Website-docu, update news (#314)

Co-authored-by: Yuri05 <[email protected]>

* Fixes #260 legend titles are updated and can be defined in themes (#315)

* Fixes #260 legend titles are updated and can be defined in themes

* Remove legend and legend title reset in boxplots

* Fixes #312 remove infinite values from plots (#316)

* fixes #318 Update website (#319)

Co-authored-by: Yuri05 <[email protected]>

* Fixes #320 Website: some images not displayed (#321)

Co-authored-by: Yuri05 <[email protected]>

* 320 attempt2 (#322)

* delete old docs folder

* Fixes #320 Website: some images not displayed

Co-authored-by: Yuri05 <[email protected]>

Co-authored-by: Pierre Chelle <[email protected]>
Co-authored-by: Indrajeet Patil <[email protected]>
Co-authored-by: Pavel Balazki <[email protected]>
Co-authored-by: Yuri05 <[email protected]>

* Improvements to the `PlotGridConfiguration` class (#293)

* Bump package version; update NEWS

* Also update website for new package version

* rest

* Update appveyor.yml

* Add print method for plot grid config

Closes #274

* document

* better example

* better headers

* add more aesthetic parameters for plot grid config

- Add needed enums
- Update NEWS for the same
- Update docs
- Add test
- Update examples

* style

* caption position

* bump version

* Add PlotAnnotationTextSize

* move enums to plot grid file

* docs

* Update PlotGridConfiguration.Rd

* needed for vdiffr tests

* move all enums to their own file

* also add watermark size to the enum (#297)

* Fixes #301 Helper function to get lines from fold distance values (#302)

* Fixes #301 Helper function to get lines from fold distance values

* Update news, doc and style

* Update NEWS.md

* Update NEWS.md

Co-authored-by: Indrajeet Patil <[email protected]>

* 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 <[email protected]>

* 308 fold distance (#311)

* 320 attempt2 (#322)

* delete old docs folder

* Fixes #320 Website: some images not displayed

Co-authored-by: Yuri05 <[email protected]>

* Fixes #325 legend title properties from argument title are used (#328)

Issue was caused because properties of R6 (Label object here) are linked if object is not cloned

* Fixes #327 horizontal bars for obs vs pred plots (#331)

- error is replaced in favor of ymin/ymax or xmin/xmax
- dataMapping initialize method needs to explicitly redefine `x` and `y` arguments because of R partial matching (if user inputs `x="a"`, partial matching would assign "a" to `xmin` instead of `x` because `xmin` was the only argument explicitly defined)

* Refresh README (#335)

* Refresh README

Closes #153
Closes #334

* remove README.Rmd

* Update README.md

* Classify vignettes on the website (#336)

Closes #178

* Make `.Rbuildignore` more comprehensive (#337)

* Make `.Rbuildignore` more comprehensive

Get rid of `NOTE` about unexpected top-level files

* Update .Rbuildignore

* Update to roxygen2 7.2.1 (#339)

* Format with latest version of styler (#341)

* Fixes #326 legend title use plot configuration for time profile plots (#343)

* Get rid of warnings and notes in R CMD check (#338)

* Fixes #333 set cap width of errorbars (#344)

* Fixes #333 set cap width of errorbars

Currently, width is a global setting applied the same way to all error bars

* Absolute cap values are now relative and width renamed to extent

Renaming width to extent to prevent user confusion when used for horizontal errorbars whose caps become vertical

* Fixes #333 cap extent renamed cap size and use consistent unit in pts

Co-authored-by: Indrajeet Patil <[email protected]>

* 303 obs map to shape (#351)

* Fixes #303 observed data map to shape

* Fixes #346 remove dynamic code

* Update documentation with latest roxygen

* format with styler

Co-authored-by: Indrajeet Patil <[email protected]>

* Fixes #353 time profile legend guide display and order shapes (#355)

* Fixes #356 display minor ticks (#357)

* Fixes #356 display minor ticks

* fix test

Co-authored-by: Indrajeet Patil <[email protected]>

* Fixes #354 ObservedDataMapping signature consistent with TimeProdfle (#358)

* Fixes #360 add linetype as internal splitting group for simulation range (#361)

* Fixes #350 default obs vs pred plot use same axes limits (#365)

The same option also centers residuals vs pred/time around 0

* format with {styler} (#366)

* Fixes #368 Add identity in Scaling enum (#371)

Also fix a typo in enum Shapes

* Fixes #375 Add spellcheck

* Fixes #362 introduce qq plots (#370)

* Fixes #362 introduce qq plots

* Remove empty y check overkill

Co-authored-by: Indrajeet Patil <[email protected]>

* Fixes #364 introduce cumulative time profile plots (#378)

* 374 enum listing molecules (#380)

* Fixes #375 enums listing all molecules, atoms and their configurations

* Fixes #379 Synchronize theme and molecule plots

* Rename Atoms and Molecules to  AtomPlots and MoleculePlots

* Fixes #381 Prevent log ticks from crashing plots (#382)

* Fixes #387 enforce factor type to prevent crash of colorBreaks (#388)

levels of character type variable is null possibly leading to null colorBreaks value

* Fixes #383 histogram can plot bars as frequency (#384)

* Fixes #383 histogram can plot bars as frequency

* Update documentation about default values of histogram

* Fixes #390 Fixes #391 observed and simulated time profiles (#393)

* Fixes #392 Create method for dual axis time profile plots (#396)

* Fixes #392 Create method for dual axis time profile plots

* Update test plot grid snapshot to latest

* Fixes #398 update documentation and website (#399)

* Fixes #398 update documentation and website

* Fixes #398 Update version and dev documentation

* Update release documentation

* Fixes #397 vignette code is run only if R version is >= 4.0 (#401)

* Increment AppVeyour version (1.4=>1.5) (#402)

Co-authored-by: Yuri05 <[email protected]>

* merge main into develop

---------

Co-authored-by: Michael Sevestre <[email protected]>
Co-authored-by: Pierre Chelle <[email protected]>
Co-authored-by: Indrajeet Patil <[email protected]>
Co-authored-by: Pavel Balazki <[email protected]>
Co-authored-by: Yuri05 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants