#! /usr/bin/env python3 # def insect_scatter3d ( ): #*****************************************************************************80 # ## 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 # import matplotlib import numpy as np import platform print ( '' ) print ( 'insect_scatter3d():' ) print ( ' matplotlib version: ' + matplotlib.__version__ ) print ( ' numpy version: ' + np.version.version ) print ( ' python version: ' + platform.python_version ( ) ) print ( ' Create a 3D scatter plot of measurements of three' ) print ( ' physical characteristics of 3 species of insects.') # # Define file names. # command_filename = "insect_commands.txt" data_a_filename = "insect_a_data.txt" data_b_filename = "insect_b_data.txt" data_c_filename = "insect_c_data.txt" plot_filename = "insect_scatter3d.png" # # Create the command file. # command_unit = open ( command_filename, 'wt' ) command_unit.write ( '# ' + command_filename + '\n' ) command_unit.write ( '#\n' ) command_unit.write ( '# Usage:\n' ) command_unit.write ( '# gnuplot < ' + command_filename + '\n' ) command_unit.write ( '#\n' ) command_unit.write ( 'set term png\n' ) command_unit.write ( 'set output "' + plot_filename + '"\n' ) command_unit.write ( 'set xlabel "<--- First Tarsus --->"\n' ) command_unit.write ( 'set ylabel "<--- Second Tarsus --->"\n' ) command_unit.write ( 'set zlabel "<--- Max Aedeagus --->"\n' ) command_unit.write ( 'set title "Measurements of 3 Insect Species"\n' ) command_unit.write ( 'set grid\n' ) command_unit.write ( 'set timestamp\n' ) command_unit.write ( 'unset key\n' ) command_unit.write ( "splot '" + data_a_filename \ + "' with points pt 7 ps 2 lt rgb 'red',\\\n" ) command_unit.write ( " '" + data_b_filename \ + "' with points pt 7 ps 2 lt rgb 'green',\\\n" ) command_unit.write ( " '" + data_c_filename \ + "' with points pt 7 ps 2 lt rgb 'blue'\n" ) command_unit.write ( 'quit\n' ) command_unit.close ( ) print ( ' Created command file "' + command_filename + '"' ) return def timestamp ( ): #*****************************************************************************80 # ## timestamp() prints the date as a timestamp. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 21 August 2019 # # Author: # # John Burkardt # import time t = time.time ( ) print ( time.ctime ( t ) ) return if ( __name__ == '__main__' ): timestamp ( ) insect_scatter3d ( ) timestamp ( )