# include # include # include # include # include # include # include using namespace std; int main ( ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // insect_scatter3d() creates a 3D scatter plot of insect measurements. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 28 September 2026 // // Author: // // John Burkardt // { string command_filename = "insect_commands.txt"; ofstream command; string data_a_filename = "insect_a_data.txt"; string data_b_filename = "insect_b_data.txt"; string data_c_filename = "insect_c_data.txt"; string plot_filename = "insect_scatter3d.png"; timestamp ( ); cout << "\n"; cout << "insect_scatter3d():\n"; cout << " C++ version\n"; cout << " Create a 3D scatter plot of measurements of three\n"; cout << " physical characteristics of 3 species of insects.\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 '<--- First Tarsus --->'\n"; command << "set ylabel '<--- Second Tarsus --->'\n"; command << "set zlabel '<--- Max Aedeagus --->'\n"; command << "set title 'Measurements of 3 Insect Species'\n"; command << "set grid\n"; command << "set timestamp\n"; command << "unset key\n"; command << "splot '" << data_a_filename << "' with points pt 7 ps 2 lt rgb 'red',\\\n"; command << " '" << data_b_filename << "' with points pt 7 ps 2 lt rgb 'green',\\\n"; command << " '" << data_c_filename << "' with points pt 7 ps 2 lt rgb 'blue'\n"; command << "quit\n"; command.close ( ); // // Terminate. // cout << "\n"; cout << "insect_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 }