metrumresearchgroup / pmplots

Plots for Pharmacometrics
https://metrumresearchgroup.github.io/pmplots
8 stars 1 forks source link

y is density not ..density.. in ggplot2 3.4.0 #75

Closed kylebaron closed 1 year ago

kylebaron commented 1 year ago

Summary

This PR fixes a bug in pmplots 0.3.6 where the density line wasn't getting drawn for npde_hist() and probably cwres_hist() too.

@callistosp Reported this in #74

The bug is fixed by using density rather than ..density.

A test was added to check the number of layers in the resulting ggplot ... 2 by default and controllable via add_density argument.

I also updated some documentation in the relevant functions; this was a little out of scope but did it anyway.

library(pmplots)
#> Loading required package: ggplot2

data <- pmplots_data_obs()

npde_hist(data) + facet_wrap(~CPc)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.


packageVersion("pmplots")
#> [1] '0.3.6.9000'

Created on 2023-02-02 with reprex v2.0.2