#! /usr/bin/env python3 # def faithful_histogram ( ): #*****************************************************************************80 # ## faithful_histogram() histograms of Old Faithful eruption durations. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 25 September 2026 # # Author: # # John Burkardt # import matplotlib import numpy as np import platform print ( '' ) print ( 'faithful_histogram():' ) print ( ' matplotlib version: ' + matplotlib.__version__ ) print ( ' numpy version: ' + np.version.version ) print ( ' python version: ' + platform.python_version ( ) ) print ( ' Histogram of Old Faithful eruption durations.' ) # # Set filenames. # header = 'faithful' command_filename = header + '_commands.txt' data_filename = header + '_data.txt' graphic_filename = header + '_histogram.png' # # Create commands. # 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 "' + graphic_filename + '"\n' ) command_unit.write ( 'set xlabel "<--- Duration --->"\n' ) command_unit.write ( 'set ylabel "<--- Frequency --->"\n' ) command_unit.write ( 'set title "Old Faithful Eruption Durations in Minutes"\n' ) command_unit.write ( 'set grid\n' ) command_unit.write ( 'set timestamp\n' ) command_unit.write ( 'set style fill solid\n' ) command_unit.write ( 'unset key\n' ) command_unit.write ( 'binwidth = 5.0\n' ) command_unit.write ( 'binstart = 40.0\n' ) command_unit.write ( 'set boxwidth 0.9*binwidth\n' ) command_unit.write ( 'plot "' + data_filename + '" i 0 using (binwidth*(floor(($2-binstart)/binwidth)+0.5)+binstart):(1.0) smooth freq with boxes lc rgb "red"\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 ( ) faithful_histogram ( ) timestamp ( )