# include # include # include # include # include # include # include using namespace std; int main ( ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // temperature_scatter3d() creates a 3D scatter plot of temperature. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 22 August 2025 // // Author: // // John Burkardt // { string command_filename = "temperature_scatter3d_commands.txt"; ofstream command; string data_filename = "temperature_data.txt"; string plot_filename = "temperature_scatter3d.png"; timestamp ( ); cout << "\n"; cout << "temperature_scatter3d():\n"; cout << " C++ version\n"; cout << " Create a 3D scatter plot of\n"; cout << " January temperatures across the US.\n"; cout << " Create corresponding gnuplot() input files.\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 '<--- Longitude --->'\n"; command << "set ylabel '<--- Latitude --->'\n"; command << "set zlabel '<--- Temperature --->'\n"; command << "set title 'January temperatures across US'\n"; command << "set view equal xyz\n"; command << "set grid\n"; command << "unset key\n"; command << "splot '" << data_filename << "' using 2:3:1 with points pt 7 ps 2\n"; command << "quit\n"; command.close ( ); // // Terminate. // cout << "\n"; cout << "temperature_scatter3d():\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 }