drc icon indicating copy to clipboard operation
drc copied to clipboard

Normalization scrambles points and curves

Open bjreisman opened this issue 4 years ago • 1 comments

Hi there, I'm a big fan of the package. I came across the following issue when using the normal = T option in plot.drc. I've included the following reproducible example.

Plotting the unnormalized data works just fine:

library(drc)
mydata <- read.csv("repex.csv")
drc.model <-  drm(abs ~ conc, drug, data = mydata, fct = LL.4())
plot(drc.model, 
     type = "average",
     normal = F, 
     col = T, 
     broken = T, 
)

image

...but when I set the normal option to TRUE, the points for labels and curves for Ap Am appear to be mismatched. The curves are correct, but the points are misplotted

plot(drc.model, 
     type = "average",
     normal = T, 
     col = T, 
     broken = T, 
)

image

Setting type = "bars" also seems to normalize the curves, but not the error bars:

plot(drc.model, 
     type = "bars",
     normal = T, 
     col = T, 
     broken = T, 
)

image

The first issue can be corrected by sorting the data alphabetically first., but in a fix it would be desirable to control the order of the points in the legend.

Happy to contribute to a potential fix. 🤓

bjreisman avatar Mar 08 '20 18:03 bjreisman