# Given a user-provided data file of values of a function z on a mesh # in the x,y-plane, this script draws a three-dimensional graph of # z(x,y) in the x,y-plane. # The name of the data file should be as specified on the splot # command below. # Assuming that the x and y positions are equally spaced, the data # file can just have the mesh z-values, one per line, with the # x-coordinate varying fastest, and a blank line between lines of # different y. In that case, the plotted x and y-values are integer, # and full xtics and ytics will need to be specified. # Otherwise you need to specify all three of x, y, and z in the data # file, one set of three numbers on each line. You should have y # going fastest, and blank lines in between lines of different x. # In Fortran terms, if i is the index in the x-direction, j the one in # the y-direction, and z(i,j) are the function values for which to # plot 3d lines, the data file could be created as: # 10 format(3g15.5) # do 30 i=1,imax # do 20 j=1,jmax # write(1,10)x(i),y(j),z(i,j) # 20 continue # write(1,10) # 30 continue # Substitute your favorite equivalent C, C++, or m code as desired. # Numbers should normally be separated by blank space, not commas. If # you have an existing data file that uses commas, like an excel file, # set the data file separator below. # Normally, you can run this script from a terminal as # gnuplot 3d.txt # In case of problems, check the error messages by using # gnuplot # load "3d.txt" # File cmmi10.pfa should be in the current folder. # Start of the script commands. # Lines starting with '# ' are comments that are ignored. Lines # starting with '#' not followed by a space are disabled commands. # You can enable such a command by removing the # # set terminal to postscript (plot size is 5 by 3 inches) set terminal postscript eps size 5, 3 enhanced \ fontfile "cmmi10.pfa" "Times-Roman" 20 # output file name of the plot set output '3d.eps' # size of the major and minor tick marks set tics scale 0.5, 0.25 # x plot range as [BEGIN:END] (use [:] to plot all x) set xrange [:] # x-axis label (see ps_guide.pdf for details) set xlabel '{/CMMI10 x}' offset 0, 0 # user-specified labels and corresponding tick positions #set xtics ("0" 0, "1" 1, "2" 2) # do not copy the ticks to the top boundary of the graph set xtics nomirror # y plot range as [BEGIN:END] (use [:] to plot all y) set yrange [:] # y-axis label (see ps_guide.pdf for details) set ylabel '{/CMMI10 y}' offset graph -0.05, 0, 0 # user-specified labels and corresponding tick positions set ytics ("0" 0, "0.5" 0.5, "1" 1) offset graph 0.05, 0, 0 # do not copy the ticks to the right boundary of the graph set ytics nomirror # z plot range as [BEGIN:END] (use [:] to plot all z) set zrange [:] # z-axis label (see ps_guide.pdf and ps_fontfile_doc.pdf for details) set zlabel '{/CMMI10 \041}' offset graph 0.05, 0, 0 # user-specified labels and corresponding tick positions set ztics ("0" 0, "0.5" 0.5, "1" 1) # do not copy the ticks to the right boundary of the graph set ztics nomirror # put labels inside the graph (see ps_guide.pdf for details) set label '{/Times-Roman White Miata Goertler Vortices}' at screen 0.33, 0.9 # set the view point, as 0 < rot_x < 180, 0 < rot_z < 360, scale, scale_z set view 60, 30, 1, 1 # put the x,y-plane at the lowest value of z set ticslevel 0 # plot the data file splot "goertler.plt" notitle with lines lt 1 lw 1 # end