#! /usr/bin/env python3 # def five_map ( ): #*****************************************************************************80 # ## five_map() makes a scatter plot of traveling salesperson data. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 06 April 2025 # # Author: # # John Burkardt # import matplotlib import matplotlib.pyplot as plt import numpy as np import platform print ( '' ) print ( 'five_map():' ) print ( ' python version: ' + platform.python_version ( ) ) print ( ' numpy version: ' + np.version.version ) print ( ' matplotlib version: ' + matplotlib.__version__ ) print ( ' Read a data file of (x,y) city coordinates.' ) print ( ' Display the data as a scatter plot.' ) # # Read the times and plasma levels from the data file. # filename = 'five_position.txt' data = np.loadtxt ( filename ) city_num = data.shape[0] names = [ 'Aspen', 'Boston', 'Clayton', 'Dayton', 'Eaton' ] # # Plot the cities. # s = 200 * np.ones ( city_num ) plt.scatter ( data[:,0], data[:,1], s ) # # Plot the names. # for i in range ( 0, city_num ): plt.text ( data[i,0], data[i,1], ' ' + names[i], fontsize = 16 ) # # Plot the roads. # for i in range ( 0, city_num ): for j in range ( i + 1, city_num ): plt.plot ( [ data[i,0], data[j,0] ], [ data[i,1], data[j,1] ] ) plt.grid ( True ) plt.xlabel ( '<--- X --->', fontsize = 16 ) plt.ylabel ( '<--- Y --->', fontsize = 16 ) plt.title ( 'Five cities for TSP', fontsize = 16 ) plt.axis ( 'equal' ) filename = 'five_map.png' plt.savefig ( filename ) print ( '' ) print ( ' Graphics saved as "' + filename + '"' ) plt.close ( ) # # Terminate. # print ( '' ) print ( 'five_map():' ) print ( ' Normal end of execution.' ) return def timestamp ( ): #*****************************************************************************80 # ## timestamp() prints the date as a timestamp. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 06 April 2013 # # Author: # # John Burkardt # import time t = time.time ( ) print ( time.ctime ( t ) ) return if ( __name__ == '__main__' ): timestamp ( ) five_map ( ) timestamp ( )