#! /usr/bin/env python3 # def humps_plot ( ): #*****************************************************************************80 # ## humps_plot() plots y=humps(x) directly from the formula. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 27 September 2026 # # Author: # # John Burkardt # import matplotlib import numpy as np import platform print ( '' ) print ( 'humps_plot():' ) print ( ' matplotlib version: ' + matplotlib.__version__ ) print ( ' numpy version: ' + np.version.version ) print ( ' python version: ' + platform.python_version ( ) ) print ( ' Plot y=humps(x) directly from the formula.' ) header = 'humps' # # Create the command file. # command_filename = header + '_commands.txt' 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 "' + header + '.png"\n' ) command_unit.write ( 'set xlabel "x"\n' ) command_unit.write ( 'set ylabel "y"\n' ) command_unit.write ( 'set title "y = humps(x)"\n' ) command_unit.write ( 'set grid\n' ) command_unit.write ( 'set timestamp\n' ) command_unit.write ( 'set style data lines\n' ) command_unit.write ( 'set xrange [0.0:2.0]\n' ) command_unit.write ( 'set samples 51\n' ) command_unit.write ( 'f(x)=1.0/((x-0.3)**2+0.01)+1.0/((x-0.9)**2+0.04)-6.0\n' ) command_unit.write ( 'plot f(x) with linespoints 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 ( ) humps_plot ( ) timestamp ( )