#! /usr/bin/env python3 # def temperature_scatter3d ( ): #*****************************************************************************80 # ## temperature_scatter3d() creates a 3D scatter plot of temperature. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 02 October 2026 # # Author: # # John Burkardt # import matplotlib import numpy as np import platform print ( '' ) print ( 'temperature_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' ) print ( ' January temperatures across the US.') # # Define file names. # command_filename = "temperature_commands.txt" data_filename = "temperature_data.txt" plot_filename = "temperature_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 "<--- Longitude --->"\n' ) command_unit.write ( 'set ylabel "<--- Latitude --->"\n' ) command_unit.write ( 'set zlabel "<--- Temperature --->"\n' ) command_unit.write ( 'set title "January temperatures across US"\n' ) command_unit.write ( 'set grid\n' ) command_unit.write ( 'set timestamp\n' ) command_unit.write ( 'set view equal xyz\n' ) command_unit.write ( 'unset key\n' ) command_unit.write ( "splot '" + data_filename \ + "' using 2:3:1 with points pt 7 ps 2\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 ( ) temperature_scatter3d ( ) timestamp ( )