ddediu / AdhereR

Computation of adherence to medications from Electronic Healthcare Data in R
26 stars 6 forks source link

CMA % not displaying on bar. #147

Closed dffyfe closed 3 years ago

dffyfe commented 3 years ago

Hi Dan,

Still having an issue with CMA% sometimes not showing on sliding window plots. Almost always happens on 'busy' plots but quite sporadically on less 'busy' plots too. Not sure if there is a way to make the cex auto based on how tight things are, defaulting at 0.8 where possible?

library(AdhereR)

cma7 <- CMA_sliding_window(CMA.to.apply = "CMA7",
                            data=med.events[med.events$PATIENT_ID %in% c(1,2,3),],
                            ID.colname = "PATIENT_ID",
                            event.date.colname = "DATE",
                            event.duration.colname = "DURATION",
                            medication.class.colname = "CATEGORY",
                            #event.daily.dose.colname = "Min",
                            carry.only.for.same.medication = FALSE,
                            followup.window.start = 0,
                            followup.window.start.unit = "days",
                            followup.window.duration = 540,
                            followup.window.duration.unit = "days",
                            observation.window.start = 180,
                            observation.window.start.unit = "days",
                            observation.window.duration = 180,
                            observation.window.duration.unit = "days",
                            sliding.window.start = 0,
                            sliding.window.start.unit = "days",
                            sliding.window.duration = 90,
                            sliding.window.duration.unit = "days",
                            sliding.window.step.duration = 180,
                            sliding.window.step.unit = "days",
                            sliding.window.no.steps = 2,
                            date.format = "%m/%d/%Y")  

plot(cma7, show.period = "dates",
       period.in.days = 60,
       show.legend = FALSE,
       ylab = c(withCMA = "Section - Drug Name"),
       cex.axis = 1,
       title = "WHATEVER",
       CMA.cex = 0.8,
       plot.CMA = T,
       #print.dose = TRUE,
       plot.CMA.as.histogram = F,
       CMA.plot.ratio = 0.000000000000000000000001,
       min.plot.size.in.characters.horiz=0,
       min.plot.size.in.characters.vert=0)
ddediu commented 3 years ago

Hi David,

I definitely see you point, but computing the cex automatically seems to be pretty tricky, but this is not the major problem, but that the text becomes illegible below a certain threshold that depends on the resolution, font anti-aliasing, etc. so, what I could do instead is give you the option to force the display of the text even if the esthetics might be less than optimal, in the form of a parameter to plot(), something like force.draw.text = TRUE, that overrides all checks -- would that work?

Also, why do you use CMA.plot.ratio = 0.000000000000000000000001? Isn't plot.CMA = FALSE doing what you want?

Best, Dan

dffyfe commented 3 years ago

Hi Dan,

Force.draw.text would be perfect.

I've been doing ...0.1 for a while now, I think when I made plot.CMA=F it was removing the grey bar above each drug/patient as well. Will try again tomorrow.

Best regards,

David

dffyfe commented 3 years ago

Yeah, plot.CMA=F is removing the grey bar too.

ddediu commented 3 years ago

Fixed (also fixed "plot.CMA=F is removing the grey bar too" aka issue #149 )