"Linux" gnuplot command Daquan

Source: Internet
Author: User
Tags cos dashed line sin

gnuplot Command Daquan

Run the gnuplot command at the Linux command prompt to start, enter quit or Q or exit.


    1. Plot command


gnuplot> plot sin (x) with line Linetype 3 LineWidth 2 or
gnuplot> plot sin (x) w L LT 3 lw 2 with line drawing, the type of line (including the type of color with the dashed line) is 3, the width of the lines is 2, the function sin (x) is plotted
gnuplot> plot sin (x) with point Pointtype 3 pointsize 2 or
gnuplot> plot sin (x) W p PT 3 PS 2 with PIP, the type of point (including the type of color and point) is 3, the point size is 2
gnuplot> plot sin (x) title ' F (x) ' W LP LT 3 LW 2 Pt 3 PS 2 while drawing with dots and lines, here title ' F (x) ' denotes the legend superscript ' F (x) ', if not used with default option
gnuplot> plot sin (x)% all options are at this time using default values. If an item is missing, the default value will be used
gnuplot> plot ' a.dat ' u 2:3 w L LT 3 lw 2 drawing using data files in the second and third columns of A.dat
By the way, as shown in the first two examples here, in gnuplot, if a certain two words, in alphabetical order, a few letters in front of the same, the latter is different, then as long as you write a different letter. If with, because there are no other words to start W, so you can use W instead, line can also use L instead.
2. Draw more than one curve at a time
gnuplot> plot sin (x) title ' Sin (x) ' W L LT 1 lw 2, cos (x) title ' cos (x) ' W L LT 2 lw 2% Two curves are separated by commas. When drawing more than one curve, each curve is separated by commas.
In the above example, the function is plotted, and if the data file is plotted, the function name can be changed to the data file name, but it should be enclosed in single quotation marks.
3, about the location of the legend
The default location is at the top right.
The gnuplot> set key left% is placed on the right, there are two options
gnuplot> set key bottom% is placed below, only this one option; default on top
Gnuplot> set key outside% is placed outside, but only on the right side, the above three options can be combined. Such as:
The gnuplot> set key left bottom% represents the right bottom and can also be used to accurately represent the location of the legend, as
Gnuplot> set key 0.5,0.6% places the legend in the 0.5,0.6 position
4. About axes
Gnuplot> set Xlabel ' x '%x axis labeled ' x '
gnuplot> set Ylabel ' y '%y axis labeled ' y '
gnuplot> set Ylabel ' dos ' TC LT 3 wherein the TC LT 3 represents ' DOS ' color with a third color.
The main scale of the gnuplot> set Xtics 1.0%x axis has a width of 1.0 and can also be defined for the y-axis ytics
Gnuplot> set Mxtics 3 on the%x axis, you can also define the y-axis by drawing 3 sub-scales in each of the main ticks Mytics
Gnuplot> Set Border 3 LT 3 LW 2 is set to a third boundary with a color type of 3 and a line width of 2
You can also set the x axis (called X2) and the right y (called y2) axis to the top, which is x2tics,mx2tics,y2tics,my2tics.
Gnuplot> Set Xtics nomirror
gnuplot> unset x2tics% above two commands remove the scale of the upper X2 axis
Gnuplot> set Ytics nomirror
gnuplot> unset y2tics% above two commands remove the scale of the right y-axis
5. Inserting text in the diagram
gnuplot> set label ' sin (x) ' at 0.5,0.5% add the string ' sin (x) ' at coordinates (0.5,0.5).
When the output is a. ps or. eps file, if you include enhanced in the statement of the set term, you can insert a subscript, a Greek letter, and a special symbol. The insertion of the upper and lower marks is the same as the method in Latex.
6. Add lines and arrows to the diagram
Gnuplot> set arrow from 0.0,0.0 to 0.6,0.8 percent (0.0,0.0) to (0.6,0.8) draw an arrowhead
Gnuplot> set arrow from 0.0,0.0 to 0.6,0.8 LT 3 LW 2 This arrow has a color type of 3 and a line width type of 2
Gnuplot> set arrow from 0.0,0.0 to 0.6,0.8 Nohead LT 3 LW 2 use Nohead to remove the head of the arrow, this is the way to add a straight line.
Note that in gnuplot, for inserting multiple labels and arrow, each label or arrow is numbered sequentially, starting with 1. If you want to remove a label or arrow later, just use the unset command to remove the corresponding. Such as:
Gnuplot> unset Arrow 2, the second one will be removed.
7, the size and position of the figure
Gnuplot>set size 0.5,0.5% length width is half of the default width, it is recommended to use this value, especially when drawing PS or EPS graphics
Gnuplot>set origin 0.0,0.5% set the bottom-left corner of the chart in the position in the graphics panel. Here the figure will appear in the upper left corner.
8. Drawing three-dimensional pictures
Gnuplot>splot ' filename ' u 2:4:5% is in the second and fourth columns as the x and Y coordinates, and the five is the z coordinate.
second, improve the article:
1. How to draw multiple graphs simultaneously in the same picture
Gnuplot>set Multiplot% set to multi-graph mode
Gnuplot>set Origin 0.0,0.0% sets the location of the origin of the first graph
Gnuplot>set size 0.5,0.5% set the first figure
Gnuplot>plot "A1.dat"
Gnuplot>set Origin 0.0,0.5% sets the location of the origin of the second graph
Gnuplot>set size 0.5,0.5% set the second figure
Gnuplot>plot "A2.dat"
Gnuplot>set origin 0.0,0.0% set the location of the origin of the third graph
Gnuplot>set size 0.5,0.5% set a third figure
Gnuplot>plot "A3.dat"
Gnuplot>set origin 0.0,0.0% set the location of the origin of the fourth figure
Gnuplot>set size 0.5,0.5% set fourth figure
Gnuplot>plot "A4.dat"
Of course, if one of the quantities in the latter figure is set to the same as the previous one, then the setting of this amount in the latter one can be omitted. For example, a setting that faces the size of the second, third, and fourth graphs. The setting for a quantity in the previous diagram also works in the latter diagram. If you want to cancel the action in the following diagram, you must use the following command, such as canceling the label, using the
Gnuplot>unset Label
2, as a two-dimensional diagram, how to make both sides of the axis of the unit length and so long
gnuplot> set size square% makes the graphic a square
gnuplot> set size 0.5,0.5% make the shape you want
Gnuplot> Set XRANGE[-A:A]
gnuplot> set YRANGE[-A:A]% two axis scale ranges
gnuplot> plot ' A.dat '
3, how to use the left and right sides of the y-axis to draw separately in the same picture
gnuplot> set xtics nomirror% Remove the scale of the above axis x2
gnuplot> set ytics nomirror% Remove the scale of the right axis y2
Gnuplot> set X2tics% to automatically generate the above axis x2 scale
Gnuplot> set Y2tics% to automatically generate the scale of the right axis y2
gnuplot> plot sin (x), cos (x) axes x1y2%cos (x) with x1y2 coordinates, axes x1y2 for x1y2 axes
gnuplot> plot sin (x), cos (x) axes x2y2%cos (x) with x2y2 coordinates, axes x2y2 for x2y2 axes
gnuplot> set X2RANGE[-20:20]% sets the range of X2 coordinates
Gnuplot> Replot
gnuplot> set Xrange[-5:5]% sets the range of x-coordinates
Gnuplot> Replot
Gnuplot> set Xlabel ' x '
Gnuplot> set X2label ' t '
gnuplot> set Ylabel ' y '
Gnuplot> set Y2label ' s '
Gnuplot> Replot
Gnuplot> set title ' The figure '
Gnuplot> Replot
Gnuplot> set X2label ' t ' textcolor Lt 3%textcolor Lt 3 or TC LT 3 set the color of the axis name
4. How to insert Greek letters and special symbols
Typically only in PS and EPS charts, and the enhanced option must be specified. cannot be displayed in the X11 terminal (that is, the monitor).
Gnuplot> Set Terminal PostScript enhanced
The Greek alphabet can then be entered by {/symbol A}. For example
Gnuplot> set label ' {/symbol A} '
For input methods of various Greek letters and special symbols, see the ps_guide.ps file in the Gnuplot-4.0.0/docs/psdoc directory in the installation package.
You can also see:
http://t16web.lanl.gov/Kawano/gnuplot/label-e.html#4.3
5, How to insert Angstrom (gnuplot) This symbol (a small circle above a)
The script joins Gnuplot>set encoding iso_8859_1 This command before inserting, and then it can be joined by "{\305}". "K (1/?)" should be labeled as the horizontal axis. :
Gnuplot>set Xlabel ' K (1/{\305})
In the case of Multiplot mode, this command must be placed before Gnuplot>set Multiplot.
If you want to insert another escape character later, add the following command after inserting the character:
Set encoding Default
The "E" in the table in the Gnuplot-4.0.0/docs/psdoc/ps_guide.ps file in the installation package represents all the symbols for that column, which are entered in this way.
6, gnuplot Painting and other high-line diagram
Gnuplot>splot ' file name. Dat ' u 1:2:3 w l% do three-dimensional diagram
Gnuplot>set dgrid3d 100,100% Set the number of meshes for a three-dimensional graph surface
Gnuplot>replot
Gnuplot>set Contour% Set Draw contour Line
Gnuplot>set cntrparam levels incremental-0.2,0.01,0.2% sets the density and range of contour lines, the data from 0.2 to 0.2 in the middle of every 0.01 draw a line
Gnuplot>unset surface to remove the above three-dimensional graphics, and finally use the mouse to drag the graphics, select a reasonable angle. or the direct setting (0,0) view can also:
Gnuplot>set View 0,0
Gnuplot>replot
Note here that the data file of the three-dimensional graph must be chunked, that is, x each transform a value, y changes in its range for a week, so as a piece, and then take an x value, y again change a week, as the next data block, and so on. The block is opened with a blank line between the blocks.
7, the output is PS or EPS chart, the following several options deserve special attention
Gnuplot>set term PostScript EPS enh solid color
The EPS option indicates that the output is in EPS format, and the default PS format is removed; The ENH option indicates that the graph can be inserted with the superscript, Greek letters and other special symbols, and if removed, it cannot be inserted; Solid option means that all the curves in the graph are solid, and that a different dashed line is removed. The color option indicates that all the curves in the graph are colored, and the color is black and white.
8, how to draw a beautiful pm3d map
Gnuplot> set Pm3d% setting Pm3d mode
gnuplot> set isosamples 50,50% setting grid point
Gnuplot> splot x**2+y**2% draw three-dimensional diagram
Gnuplot> splot x**2+y**2 w pm3d% painted Pm3d mode, pay attention to the difference
gnuplot> set view 0,0% set angle of view, (0,0) will be projected to the end of the face up
Gnuplot> splot x**2+y**2 w pm3d% re-painting, pay attention to see the change
gnuplot> unset ztics% Remove the numbers on the z-axis
Gnuplot> set Isosamples 200,200 makes the mesh thinner
Gnuplot> Replot% re-painting, pay attention to change, mainly transition smoother
9. Avoid duplicate input with script file
Sometimes when you make a picture of a data file, you might want to use the data file for the next time, but some or some of the settings are slightly different. At this time, you can write the first time when the command is written in a file, such as A.PLT, the next time as long as the corresponding settings are modified, the following command will automatically run the file all the commands and finally get the picture you want: gnuplot>load ' a.plt '
As an example, suppose the file name is A.PLT and the contents are:
Set Pm3d
Set View 0,0
Unset ztics
Set Isosamples 200,200
Splot x**2+y**2 W Pm3d
Set term post color
Set Output ' a.ps '
Replot
Then when you start Gnuplot, just run the following command:
Gnuplot>load ' A.PLT '
If we're going to get just a. ps or. EPS graph, you can also run the following commands directly from the Linux command prompt:
[[email protected] zxh] $gnuplot a.plt
10. Running the Linux command in gnuplot mode
You can also run the Linux command at the gnuplot prompt, but you must precede the corresponding command! No. For example, suppose that a number of parameters have been set, but you need to modify a data file A.dat and then draw, you can use the following method
Gnuplot>!vi A.dat
In this way, all Linux commands can be run in the gnuplot environment.
In addition, you can also enter the shell after the gnuplot prompt, temporarily exit gnuplot, into the Linux environment, after doing things to do, run the exit command, and back to the gnuplot environment.
Gnuplot>shell
[[email protected] zxh] $vi A.F
[[email protected] zxh] $f A.F
[[email protected] zxh] $a. Out (assuming the A.dat data file is generated)
[[email protected] zxh] $exit
Gnuplot>plot ' A.dat ' w l

"Linux" gnuplot command Daquan

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.