I wrote a short article a few years ago. When I was searching for something today, I found it useful. Put it here for your reference. 3D plot example 11: splot [-pi: pi] [-pi: pi] sin (x) * cos (y) generate results-draw a sin (x) * cos (y) graph using a network consisting of 10 lines. Plottingsin (x) * co
I wrote a short article a few years ago. When I was searching for something today, I found it useful. Put it here for your reference. 3D plot example 11: splot [-pi: pi] [-pi: pi] sin (x) * cos (y) generate the result in Figure 2-draw a sin (x) * cos (y) graph using a network consisting of 10 lines in the vertical and horizontal directions. Figure 3 Plottingsin (x) * co
I wrote a short article a few years ago. When I was searching for something today, I found it useful. Put it here for your reference.
3D drawing
Example 11:
splot [-pi:pi] [-pi:pi] sin(x)*cos(y)
Generate the result in Figure 2-draw a sin (x) * cos (y) image from a grid consisting of 10 lines in the vertical and horizontal directions.
Figure 3 plow.sin (x) * cos (y)
Example 12 draw a contour map:
Set dgrid3d 100,100 # set the number of grids on the three-dimensional chart surface set contour # set to draw a contour line set cntrparam levels incremental-0.9, 0.1, 0.9 # set the density and range of the contour lines, draw a line from-0.2 to 0.2 at intervals of 0.01 unset surface # Remove the preceding 3D image set view, 0 unset keysplot [-pi: pi] [-pi: pi] sin (x) * cos (y)
Example 13 pm3d Images
set pm3dset isosamples 50,50splot x**2+y**2
Set view # sets the angle of view. () It projects the final surface to unset ztics # removes the number on the Z axis from unset surfacesplot x ** 2 + y ** 2 reset
Output file
When starting, you may notice that the terminal type is set to X11. Gnuplot adopts a standard design and can be drawn on multiple terminal devices. This includes printing directly to multiple printers, including Epson, HP, and Imagen printers. It can even be drawn in pseudo devices, such as postscript and png. This mainly involves generating output files, rather than viewing files or printing output. This is a trick to include your chart in other reports.
Example 14 set the output and terminal types
set terminal png # gnuplot recommends setting terminal before outputset output ‘output.png’ # The output filenameplot sin(x)
Now, the file output.png contains the image you just created.
All terminals have different capabilities. Some of them (such as LaTeX) may not support text rotation, so if you set ylabel as we did before, it may be displayed differently on different terminals. In other words, you can use the LaTeX command on a specific LaTex terminal. For example, set ylabel $ sin (\\\\ theta) $ (note that we use two backslash to generate a backslash required by LaTex -- gnuplot first performs backslash processing before passing the string enclosed in double quotation marks to the terminal driver ). Now, you can use \ input {output. tex} to include the output file in the LaTeX file. To obtain the same results in the PostScript terminal, use the corresponding PostScript command: {/Symbol q }. In enhanced PostScript and LaTeX, you can use the notation x ^ {superscript} and x _ {subscript} to obtain the superscript. Pay attention to the abbreviated terminal and output commands:
Example 15 capabilities of the eps driver
set term post enh # enhanced PostScript, essentially PostScript with bounding boxesset out 'gplt.eps'set xlabel '{/Symbol q_1}set ylabel 'sin^2({/Symbol q_1})'plot sin(x)**2Others
By the way, all the examples we provide can run in interactive mode or batch mode. To run in interactive mode, enter each command in the prompt. To run in batch mode, enter the command or add it to a text file, and then use the load 'filename' command at the gnuplot prompt to read the file, or, at the shell prompt, provide it as a parameter to gnuplot: $ gnuplot filename. Using the second method, gnuplot exits after executing all the commands in the input file. Therefore, when directly drawing to the file, the execution in batch mode is particularly effective. If the second method is used for drawing on the screen, the output window disappears as soon as it appears (when gnuplot exits, therefore, you need to use the explicit "pause-1" command (see help pause) to keep the window.
In the X environment, like other X client programs, gnuplot can accept many parameters. For example
Gnuplot-font 8x13bold # Set the font to 8x13bold. Gnuplot-geometry 900x700 # Set the Window Length to 900 pixel and the width to 700 pixel. Gnuplot-bg black # Set the background color to black.
The steps for drawing mathematical functions or numerical data using gnuplot are as follows:
Define constants and functions: Define constants and functions to make programs modular and easy to understand.
Set drawing environment: Many drawing parameters have been pre-set before gnuplot drawing.
Drawing: After defining a mathematical function or setting a drawing environment, draw a graph of a mathematical function or numerical data. Gnuplot provides easy-to-use plotting commands-plot (2D) or splot (3D ).
Output Result: After the result is drawn on the terminal, the output required by different output devices can be generated through some steps.
Based on the above process, you can quickly draw images. The remaining steps are to carefully adjust the drawing environment parameters or modify the function equations and constants to produce satisfactory results.