#*****************************************************************************80 # ## circle_scatters plots data in and out of a circle. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 02 September 2020 # # Author: # # John Burkardt # cat ( date ( ), "\n" ) cat ( "\n" ) cat ( "circle_scatters\n" ) cat ( " ", version$version.string, "\n" ) cat ( " Make scatter plots of two sets of data representing" ) cat ( " points inside, and points outside the unit circle." ) # # Read the data. # filename = "circle1_data.txt" data1 <- read.table ( filename, header = FALSE ) filename = "circle2_data.txt" data2 <- read.table ( filename, header = FALSE ) # # Generate points on a circle. # n = 50 circle = matrix ( nrow = n, ncol = 2 ) for ( i in 1 : n ) { theta = 2 * pi * ( i - 1 ) / ( n - 1 ) circle[i,1] <- cos ( theta ); circle[i,2] <- sin ( theta ); } # # Plot the data # filename = "circle_scatters.png" png ( filename ) plot ( circle[,1], circle[,2], lwd = 3, type = "l", col = "black", xlab = "<--- X --->", ylab = "<--- Y --->", main = "Random points inside/outside the unit circle" ) points ( data1[,1], data1[,2], col = "blue" ) points ( data2[,1], data2[,2], col = "red" ) grid ( ) cat ( ' Graphics saved as "', filename, '"\n' ) # # Terminate. # cat ( "\n" ) cat ( "circle_scatters:\n" ) cat ( " Normal end of execution.\n" ) quit ( )