metrumresearchgroup / pmplots

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

npde_hist smooth line missing in version 0.3.6 #74

Closed callistosp closed 1 year ago

callistosp commented 1 year ago

We recently updated some old code to use pmplots v0.3.6 instead of v0.3.3. When this was done the smooth line in npde_hist no longer appears. I reran the code using v0.3.5 and the line was there, so it appears to be due to either some change between these two versions or, more likely, an issue with another package on the 2023-01-25 MPN snapshot.

00b1496a-28a6-44f4-aca6-e610af2e24b0

seth127 commented 1 year ago

Yep, I would bet this has something to do with the recent (minorly infamous) ggplot2 change related to linewidth.

It looks like npde_hist() ultimately filters through to cont_hist(), which calls add_density() to get that line, which... was changed to accomodate that ggplot2 release.

I'm not sure if this is something we should change in pmplots or if it's part of another package, as @callistosp suspects, but we should definitely look into it and try to get a patch release out before the next MPN.

kylebaron commented 1 year ago

@callistosp - Thanks for the report. Can you try passing add_density through to force this to get drawn?

library(pmplots)
#> Loading required package: ggplot2

data <- pmplots_data_obs()

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

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

I think the name of those stats also changed and we were just checking for the wrong value there.

Kyle

callistosp commented 1 year ago

yes, I can confirm that adding add_density = TRUE brings the smooth line back on the histograms. Thanks for the quick diagnosis!