#*****************************************************************************80 # ## drug_dosage_plots models the variation in blood levels of a medicinal drug. # # Discussion: # # Drug levels in the blood, for certain drugs, can be modeled by a pair of # coupled first-order linear differential equations. # # The concentration level must reach 800 mg / liter to be medicinally # effective but becomes toxic at 1000 mg / liter. # # It is desired to plot the concentration level, as well as two horizontal # lines representing the medicinal and toxic levels. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 23 August 2020 # # Author: # # John Burkardt # # Reference: # # Soraya Dhillon, Andrzej Kostrzewski, # Clinical Pharmacokinetics, # Pharamceutical Press, 2006, # ISBN: 978-0-85369-571-4. # cat ( "\n" ) cat ( "drug_dosage_plots:\n" ) cat ( " ", version$version.string, "\n" ) cat ( " Plot the variation over time of the concentration\n" ); cat ( " of a medicinal drug in the bloodstream.\n" ); filename = "drug_dosage_data.txt" data <- read.table ( filename, header = FALSE ) times = data[,1] cc = data[,2] n = dim(data)[1] # # Plot the data. # filename = "drug_dosage_plots.png" png ( filename ) plot ( times, cc, xlab = "<--- Time --->", ylab = "<--- Plasma concentration --->", main = "Drug level variation over time", col = "blue", type = 'l', lwd = 4, ylim = c ( 0, 1100 ) ) t2 = c ( times[1], times[n] ) m2 = c ( 800, 800 ) lines ( t2, m2, type = 'l', col = "green", lwd = 4 ) t3 = c ( times[1], times[n] ) m3 = c ( 1000, 1000 ) lines ( t3, m3, type = 'l', col = "red", lwd = 4 ) x = 5.0 y = 200.0 legend ( x, y, legend = c ( 'blue: Plasma Concentration', 'green: Medicinal Level', 'red: Toxic Level' ) ) grid ( ) cat ( "\n" ) cat ( " Graphics saved as '", filename, "'\n" ) # # Terminate. # cat ( "\n" ) cat ( "drug_dosage_plots\n" ) cat ( " Normal end of execution.\n" ) quit ( )