# include # include # include # include # include # include # include using namespace std; int main ( ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // automobile_scatter() creates a scatter plot of Corvette sale price data. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 06 September 2026 // // Author: // // John Burkardt // { string command_filename = "automobile_commands.txt"; ofstream command; string data_filename = "automobile_data.txt"; string plot_filename = "automobile_scatter.png"; timestamp ( ); cout << "\n"; cout << "automobile_scatter():\n"; cout << " C++ version\n"; cout << " Create a scatter plot of automobile price versus weight.\n"; // // Create the command file. // command.open ( command_filename.c_str ( ) ); command << "# " << command_filename << "\n"; command << "#\n"; command << "# Usage:\n"; command << "# gnuplot < " << command_filename << "\n"; command << "#\n"; command << "set term png\n"; command << "set output '" << plot_filename << "'\n"; command << "set xlabel '<--- Price in 1985 Dollars --->'\n"; command << "set ylabel '<--- Curb weight in Pounds --->'\n"; command << "set title 'Automobile Price vs Weight'\n"; command << "set grid\n"; command << "set timestamp\n"; command << "unset key\n"; command << "set style data lines\n"; command << "plot '" << data_filename << "' using 1:2 with points pt 7 ps 2 lc rgb 'red'\n"; command << "quit\n"; command.close ( ); // // Terminate. // cout << "\n"; cout << "automobile_scatter():\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void timestamp ( ) //****************************************************************************80 // // Purpose: // // timestamp() prints the current YMDHMS date as a time stamp. // // Example: // // 31 May 2001 09:45:54 AM // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 19 March 2018 // // Author: // // John Burkardt // { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct std::tm *tm_ptr; std::time_t now; now = std::time ( NULL ); tm_ptr = std::localtime ( &now ); std::strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm_ptr ); std::cout << time_buffer << "\n"; return; # undef TIME_SIZE }