Currently I have a simulated data set describing the concentration-time profile of a drug at 10 different doses, with five replications ("subjects") for each dosing group. I am trying to create one file with plots for each dose, with the median concentration plotted as a dashed line, and a shaded confidence interval which I hoped to achieve with polygon()
.
# vector with the simulated doses
dvec <- c(0.1, 0.3, 1, 3, 10, 30, 100, 300, 500, 1000)
win.metafile("indv_plot.wmf", width = 25, height = 20)
par(mfrow = c(2, 5))
for (bb in c(1:10)) {
## sumdat is a data file which has summary statistics and CI
dose_d <- sumdat[sumdat$DOSE == dvec[bb], ]
plot(dose_d$TIME, dose_d$OBS_MED,
type = "n", lty = 2, col = "black",
xlab = "Time (hr)", ylab = "Plasma Concentration",
main = paste("DOSE=", dvec[bb]))
polygon(c(dose_d$TIME, rev(dose_d$TIME)), c(dose_d$LPL_MED, rev(dose_d$UPL_MED)),
col = "salmon", border = "red")
}
There are two problems I have when running this code:
polygon()
seems to be successful in generating the shaded region I want, but my dashed line is nohere to be seen on the graph. How do I appropriately overlay this so that both can be seen?- In the
.wmf
file, the y-axes are extremely misleading (scaled so that each of the 10 graphs looks nearly identical!) and cut off part of the shaded region, such that you can no longer see the peak of the curve. How do I fix this scaling? Please note that the doses cover a 10k fold range.
EDIT: Here is a sample of the spreadsheet I'm working with with the numbers slightly different from the ones I'm working with.
DOSE TIME OBS_MED LPL_MED UPL_MED
0.1 0.25 0.00133825 0.001223836 0.002291141
0.1 0.5 0.001747625 0.002151059 0.003686252
0.1 1 0.00308325 0.003017057 0.005157501
0.1 2 0.003539375 0.003388839 0.005425594
0.1 3 0.002771875 0.003205603 0.004896142
0.1 5 0.002286875 0.002368057 0.003719701
0.1 7 0.0020495 0.00164708 0.002937914
0.1 12 0.001414625 0.000644596 0.001710477
30 0.25 0.760858151 0.275588118 0.470376128
30 0.5 0.749280163 0.468870272 0.774292746
30 1 1.264732715 0.677246853 1.069407039
30 2 1.219044091 0.769589233 1.148778861
30 3 1.084113451 0.70481485 1.06030292
30 5 1.014486376 0.527557896 0.791142911
30 7 0.600676092 0.368193808 0.610086631
30 12 0.287301205 0.138354359 0.371749849