#*****************************************************************************80 # ## price_plots reads price data and plots 3 prices on one display. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 25 August 2020 # # Author: # # John Burkardt # cat ( "\n" ) cat ( "price_plots:\n" ) cat ( " ", version$version.string, "\n" ) cat ( " Plot prices of bananas, gas and milk over time.\n" ) # # Read the data. # filename = "price_data.txt" data <- read.table ( filename, header = FALSE ) n = dim(data)[1] x = seq ( 1, n ) # # Plot three curves on one image. # filename = "price_plots.png" png ( filename ) plot ( x, data[,3], xlab = "<--- Month index --->", ylab = "<--- Price in Dollars --->", main = "Prices, Feb 2008-Feb 2018", col = "red", type = 'l', lwd = 3, ylim = c ( 0.0, 5.0 ) ) lines ( x, data[,10], type = 'l', col = "blue", lwd = 3 ) lines ( x, data[,13], type = 'l', col = "green", lwd = 3 ) x = 25.0 y = 4.0 legend ( x, y, legend = c ( "red: Bananas", "blue: Gas", "green: Milk" ) ) grid ( ) cat ( "\n" ) cat ( " Graphics saved as '", filename, "'\n" ) # # Terminate. # cat ( "\n" ) cat ( "price_plots\n" ) cat ( " Normal end of execution.\n" ) quit ( )