Gnuplot Drawing Skills Summary

Source: Internet
Author: User
Tags mathematical functions

---------------------------------------------------------------------------------------------------------

This article welcome reprint, reprint please attach link http://blog.csdn.net/iemyxie/article/details/41548583

---------------------------------------------------------------------------------------------------------

Recently with gnuplot painted a lot of pictures, the key word god horse every use to re-check the use of documents, simply God annoying. So simply summarize the usual techniques for future reference.


I. Introduction of Gnuplot

Maybe I said a long while people do not build gnuplot is a what thing. Gnuplot, lightweight drawing artifact. Put on Wikipedia's explanation: Gnuplot is a set of cross-platform mathematical drawing free software. Using the interactive interface, you can draw mathematical function graphs, or you can read from plain text files into simple format coordinates, draw statistical charts, etc. It is not a statistical software, nor is it a mathematical software, it is purely a set of function/data mapping software. It can produce PNG,SVG,PS,HPGL, ... And so on the output of the open graphic file format for clerical processing/presentation/trial calculation/... Wait for the software to import.
Function:
Painting two-dimensional or three-dimensional images
Mathematical functions of painting
Reading data from other documents, drawing statistical charts
Called by an external program (such as GNU Octave)

Click to download Gnuplot

Second, draw a point

First to put a Bo master first contact with the gnuplot painting.


Attach some code:

Set term post EPS color ENH solid//fixed format set term Pdfcairo LW 2 font ' times_new_roman,8 ' datafile= ' Afterp-h-kmeans++-k=6.dat A ' Set output ' afterp-h-kmeans++-k=6.pdf ' Set title ' Afterp-h-kmeans++-k=6 '

A.

Set: All gnuplot settings start with Set
? Term: terminal, terminal, indicates the format of the image input and output. Can be followed by post eps,png,jpg, etc.
? Color: can output color pictures and curves
? Enh:enhance, strengthen, can enter various symbols, such as the Greek alphabet.
? Solid: You can use solid lines.
? datafile= "xxx.data" data file, the file can be no suffix, or txt, or data can be.
? The set output "xxx.jpg" outputs a picture named Xxx.jpg?

? The using 7:1 means that the 7th column of the data file is used as the x-axis, and the 1th column as the y-axis. Note the value of the x-axis is in front.

?" With points "that is the PIP point.

B.

The position of key placement can be adjusted according to different requirements.

The Official Handbook explains the following:

Set key {On|off} {default}
{{inside | outside} | {Lmargin | rmargin | tmargin | bmargin}
| {at <position>}}
{left | right | center} {TOP | bottom | center}
{Vertical | horizontal} {left | Right}
{{No}opaque}
{{No}reverse} {{No}invert}
{samplen <sample_length>} {spacing <vertical_spacing>}
{width <width_increment>}
{height {{no}autotitle {ColumnHeader}}
{title "< Text> "} {{no}enhanced}
{font" <face>,<size> "} {TextColor < Colorspec>}
{{no}box {{linestyle | ls <line_style>}
| {Linetype | lt <line_type>}
{linewidth | lw <line_width>}}}
{maxcols {<max No. of Columns> | Auto}}
{maxrows {<max No. of Rows> | Auto}}
unset key
show key

Remember some common things: vertical: vertical arrangement;Horizontal: horizontal arrangement; Right top: Upper left corner; Top top: The upper-upper corner; Outside: Place outside the picture; inside: Inside the picture.

C.
How does it work? You can save the code as "Xxx.gnu" and enter it on the command line:gnuplot Xxx.gnu

or Save as "xxx.plt" so you can double-click this text document to get the result, of course your code must be correct. Otherwise. Your image will be 0k in size.

Recommend the second method, more convenient.

Second, draw the line

A. Single line

As usual, let's put a picture of yourself with a gnuplot.


Very simple, you can see the code.

Set term post EPS color enh solidset term pdfcairo lw 2 font ' times_new_roman,8 ' datafile= ' realduration ' Set output ' Realdur Ation-w1t1.pdf ' Set Xlabel ' time (ms) '//Set horizontal axis name set Ylabel ' Duration (ms) '//Set vertical axis Name set grid//Show grid plot datafile using 6:4 N in Figure Otitle with lines set output
B. Draw multiple lines and smooth processing

The smoothing option specifies how to smooth the lines between data. In order to make the data cartography beautiful and reasonable, the curves plotted according to the data have different smoothing algorithms.
Smooth {Unique | frequency | cumulative | cnormal | kdensity| csplines | acsplines | bézier | sbezier}

The Autoscale option opens so that the smoothing curve is overall within the picture boundary.
The Autoscale is not turned on, and the smoothing option is acspine and Cspline, and the curve sample passes through the X area of the input data.
Acsplines Natural Spline smoothing. Data Local about x monotone, curve is piecewise function. Three-time polynomial construction with coefficients conforming to input weights.
The weights are represented by the third input column.
Plot ' Data-file ' using 1:2: (1.0) Smooth Acsplines
The order of magnitude of the input weights will qualitatively affect the number of segments of the curve. If a weight is large, the point to which it is located has a greater effect on the curve.
The curve approximates the 3 natural spline curves that connect each point. If the weights are small, the curves consist of several small fragments, which are generally smooth.
The limit condition is that a single fragment is generated by a weighted linear least squares approximation of all data. Data errors can be used as smoothing weights.

Example: (The following two pictures from @ivan)

Command:
Plot "Price.dat" using 1:2 with Linespoints, "using 1:2 title" Bezier "Smooth Bézier," "Using 1:2 title" Csplines "Smooth Csplines


Plot [1975:1995][40:160] "Price.dat" using 1:2 with points title "Price.dat", "" "U 1:2: (1) Smooth acsplines title" 1 "," " Using 1:2: (1/50.) Smooth acsplines title "1/50", "Using 1:2: () Smooth acsplines title" "," "Using 1:2: (1/10000.) Smooth acsplines title "1/10000"


The method of drawing multiple lines is also very simple: as shown above, plot "xxx", "xxx2", "xxx3" can be

Iii. types of lines and points


in EMF format, the gnuplot is available in 15 different colors Lt 1 to Lt 15. Lt 16 is also red, but the line becomes dashed.


The first 30 points, lines in the EMF format


---------------------------------------------------------------------------------------------------------

This article welcome reprint, reprint please attach link http://blog.csdn.net/iemyxie/article/details/41548583

---------------------------------------------------------------------------------------------------------

Gnuplot Drawing Skills Summary

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.