#*****************************************************************************80 # ## grid_surface draws a surface from a table Z(X,Y). # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 30 August 2020 # # Author: # # John Burkardt # cat ( "\n" ) cat ( "grid_surface:\n" ) cat ( " ", version$version.string, "\n" ) cat ( " Make a surface plot Z(X,Y) for a 41x41 table.\n" ) # # Read the data. # filename = 'grid_data.txt' xyz <- read.table ( file = filename, header = FALSE ) # # Convert Z data to a matrix. # x = seq ( from = -2.0, to = +2.0, len = 41 ) y = seq ( from = -2.0, to = +2.0, len = 41 ) z.matrix <- matrix ( xyz[,3], nrow = 41, ncol = 41 ) filename = 'grid_surface.png' png ( filename ) persp ( x, y, z.matrix, theta = 60, phi = 30, main = "Surface plot of 41x41 table Z(X,Y)", xlab = "<-- X -->", ylab = "<-- Y -->", zlab = "<-- Z(X,Y) -->", col = "magenta" ) cat ( "\n" ) cat ( " Graphics saved as '", filename, "'\n" ) # # Terminate. # cat ( "\n" ) cat ( "grid_surface:\n" ) cat ( " Normal end of execution.\n" ) quit ( )