21 views

Uploaded by e_tzirin

- Module 4
- latex2e.pdf
- Mathematics Latex Guide
- LaTeX Help Beginner
- floatflt
- Latex Nec Cse
- LaTeX2e for Class and Package Writers
- endnotes.pdf
- Draft Conference
- (Tex eBook) - Advanced Latex
- Function-Blocks-Overview-CENTUM-VP.pdf
- empheq package
- PLC Scan.pptx
- Lec01 Intro CSCI C++
- Omron Plc & Remote Io - Cat2014
- 2 Example of Design stage – Video Library part 1
- Twin Cat Module 1
- cp1e_p061-e1_14_1_csm2118
- Et200m Im 153 2 Product Info en en-US
- DSQFM-TRX-2

You are on page 1of 9

David Kotz Principal author of this tutorial for gnuplot 3.0, July 3, 1991

current gnuplot team Updates of this tutorial for gnuplot 4.0, March 2004 Update of this tutorial for gnuplot 4.2, August 2006 Update of this tutorial for gnuplot 4.4, September 2010

Contents

1 Introduction and History

A 2 Using gnuplot for L TEX: a Tutorial A 2.1 Summary — Use with L TEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1 1 5 6 7 7 7 7

**3 Use with EEPIC
**

A 4 What is new for TEX and L TEX terminals in gnuplot 4.0 A 5 What is new for TEX and L TEX terminals in gnuplot 4.4

6 Sample of epslatex terminal driver 7 Contact for help

For example.0. we direct the output explicitly with an instruction to gnuplot (the set output "outfile.4 1 1 Introduction and History Gnuplot was originally developed by Colin Kelley and Thomas Williams in 1986 to plot functions and data ﬁles on a variety of terminals.tex" plot [-3. and plots y = sin(x) for x on [−π. 1 In gnuplot version 4.shar from cs. I simply \input{eg1} in a center environment in a figure environment. all of the commands to gnuplot are contained in the ﬁle plotcommands. i. gives a ﬁle name for the output. After printing.. A X faster. the program need not be run on a graphics terminal. If an enlarged version of TEX is available. I added a number of embellishments. 2. so gnuplot would output L TEX code. i. This includes.tex" command). a L TEX driver derived from A X should read the next section.gp. . the one in GnuTEX. Gnuplot continues to print error messages to the terminal (stderr). gnuplot plotcommands.duke. Multiple ﬁlenames may be supplied to gnuplot this way. set terminal latex set output "eg1. Whenever hard copy is desired from gnuplot.) The terminal type fig outputs FIG code that can be read by the Fig graphics A program and translated into forms usable in both TEX and L TEX documents. intended for use with the EEPIC macro package for L TEX.0. labeled the tic marks for us. keep your plots simple and add \clearpage to your document where necessary. known as GnuTEX. 2 A Using gnuplot for LTEX: a Tutorial A Gnuplot is by nature an interactive program. Otherwise. The plot could then be A X document. Users making plots for L TEX will generally not use gnuplot interactively. The input ﬁle deﬁnes the output to be in L TEX. (A shell script (lasergnu) is supplied with the distribution that will accept a gnuplot command or input ﬁle and send the output to an Imagen or Postscript laser printer. supported only by the latex terminal. The gnuplot input ﬁle is given A below. the output ﬁle has to be closed by set output. This script may have been adapted to your site. output from the terminal type unixplot may be sent to a program interpreting the Unix plotting standard. In following examples.e. that A supported a new “terminal type” called latex. read in the order they are given.edu. In 1988 and 1989 I created an alternate version. a tutorial.A Gnuplot L TEX Tutorial Version 4. A The reader should note that the L TEX picture environments output by gnuplot can be quite large and complicated. A There is also an EEPIC driver (eepic). then sent to the appropriate output device. and added a key in the upper-right-hand corner (this may be moved with the set key command.14] sin(x) Note that gnuplot has drawn in the axes. I will enclose the ﬁgure in a box to make it look a little better. producing a plot for this document. included in a L TE allowing the user to produce publication-quality plots.gp In this example. runs through L TE Section 3 for more information. Usually. See EEPIC allows for much more eﬃcient line-drawing. it is wise to use it. In late 1989 and early 1990 GnuTEX and a number of other gnuplot variants were merged together into A a new release of gnuplot. A There is a small package of auxiliary ﬁles (makeﬁles and scripts) that I ﬁnd useful for making L TEX plots with gnuplot. π]. and the output appears as Figure 1. Example 1: Here is a ﬁrst example. however.14:3. The terminal types imagen and postscript may be used for output to printers understanding those languages. without the ﬁle name speciﬁcation. To produce the ﬁgure. and removed with unset key1 ). Anyone interested in using gnuplot with L TE and the primary gnuplot manual. the syntax set noXXX changed to unset XXX. and uses less memory.e. among many other improvements. In this case the output is directed to a ﬁle or pipe. scaled the y axis automatically. The output (one or more plots) may be piped to another program or redirected to a ﬁle. and can easily exceed the memory capacity of TEX. We now ignore the interactive nature of gnuplot and provide the input to gnuplot from a ﬁle. This is available for ftp as pub/gnuplot-latex.

5cm set output "eg2.4 0.2 0 0 1 2 3 4 5 This is the x axis 6 sin(x) Figure 2: A fancier example. Because of the limited picture capabilities of L TEX. including space for the labels.28] [0:1] sin(x) This is a plot of y = sin(x) 1 0. This may overload the memory of many TEX implementations.6 -0. In the ﬁrst example. This is the size of the area used by the plot. command.4 0. Example 2: Now we will embellish the plot a little with some labels.8 -1 -3 -2 -1 0 1 2 3 Figure 1: A ﬁrst example: y = sin(x). A A This is the default line style for the L TEX driver. set terminal latex size 7cm.A Gnuplot L TEX Tutorial Version 4.8 0..6 0.6 the y axis0.4 -0. this size was the default 5 inches by 3 inches. This input ﬁle produces Figure 2.4 2 1 sin(x) 0.tex" set format xy "$%g$" set title ’This is a plot of $y=\sin(x)$’ set xlabel ’This is the $x$ axis’ set ylabel ’This is\\the\\$y$ axis’ plot [0:6. many dots are required to approximate drawing a solid line. We have speciﬁed the plot to be 7 cm wide and 5 cm tall with the set term latex size .8 This is 0. .2 -0..2 0 -0. There are other line types available that draw dotted lines and use much less memory. The EEPIC driver draws solid lines with much less memory usage.

In this case. Note that they are A processed by L TEX and so may have math mode and other symbols in them. so generally each plot has its own input ﬁle and is kept in a separate output (. each plot command generates a new plot. Any valid ﬂoating-point A formatting speciﬁcation. It is not likely that L TEX users will want this to happen.dat” × 5 10 15 20 Figure 3: An example with two curves on the same plot. unless speciﬁed by the user. The default is set format xy "%g". The ylabel can be moved around with optional oﬀset parameters (see set ylabel in the gnuplot manual). and is shown here to illustrate the plot style option. but (of course) any A L TEX code in the string will not be interpreted. . These labels are also supported by the other terminal types. This plot is shown in Figure 3. a new page is produced. set terminal latex set output "eg3. This makes the labels look a little better. a style like lines that also plots a symbol at each data point. Here you will see that the x range was not speciﬁed.tex) ﬁle for inclusion at diﬀerent places in the document.4 3 A We have requested that the format used by the x. is allowed in the format. In our next example. If the output is to a screen.and y-axis tic mark labels be in L TEX math mode. the screen is cleared.dat is plotted with style linespoints. a new picture is started. In the A latex case.tex" set format xy "$%g$" set title "This is another plot" set xlabel "$x$ axis" set ylabel "$y$ axis" set key at 15. The function y = x is plotted “with lines”. We have also moved the key to a diﬀerent position. on one plot.dat". If to a printer. Typically. So far we have plotted one curve. the default range of [−10 : 10] is used. The x range is determined automatically. The %g represents the general-purpose ﬂoating point formatting speciﬁcation for the printf function in C. We have also deﬁned the range of both x (now [0. "eg3. it is deﬁned by the range of the data ﬁle "eg3. A title for the plot and labels for the axes were set up in the next three commands.-10 plot x with lines. we will plot both a function and a data ﬁle on the same plot. The data ﬁle eg3. delineated with \\. If no data ﬁles or x range are supplied. 2π]) and y (here [0. Example 3: To place more than one curve on a plot. they will be used for all subsequent plot commands until they are changed. The ylabel may have multiple lines. Once these labels are set up. the ylabel needs to be moved to the left to avoid interfering with the left-hand side of the plot.dat" with linespoints This is another plot 20 15 10 5 y axis 0 −5 ×××××××××××××××× ×× × × × × ×××× ××× −10 ××××××××××× −15 −20 −20 −15 −10 −5 0 x axis x ”eg3. In gnuplot. The function is plotted over the same range.A Gnuplot L TEX Tutorial Version 4. 1]). y = sin(x). or L TEX command. which is the default plot style for functions. use one plot statement and separate the description of each curve by a comma.

Replacing the above set xtics command with the following gives us Figure 5. with the set xtics and set ytics commands. to spread out this command for readability. and another called dots that plots a tiny dot for each data point. The lines and linespoints styles use a diﬀerent line style for each curve on the plot (in this example the dots have diﬀerent spacing). the errorbars style can draw error bars at each data point (see the gnuplot manual). as in the title. Example 4: In the above plots of sin(x).5 −1 −3.\ .A Gnuplot L TEX Tutorial Version 4. The position and labels of the tic labels may be speciﬁed by the user. so the backslash had to be escaped. (The exception: a backslash at the end of a line—even within single quotes—is used by gnuplot for line continuation. Since pi is a predeﬁned variable in gnuplot.14 −2. it would make more sense to label the axis in units of π. Note that the y axis label was delimited by double quotes.36 3.tex" set format y "$%g$" set format x "$%. Another form of this command allows us to specify the label and position of each tic individually. The points and linespoints styles produce a diﬀerent point symbol for each curve on the plot (for up to twelve symbols. set xtics (’$-\pi$’ -pi.14 Figure 4: An example of the set xtics command. see Figure 8 for a complete list).79 This is the x axis 1. We have also turned oﬀ the key. We also make use of the line continuation character. we can use it anywhere we may use an expression.57 2.\ ’$-\frac{\pi}{2}$’ -pi/2.57 −0.) With a little more work. The set xtics command here speciﬁes that the tics on the x axis start at −π and increment by π/4. after which they are re-used. gnuplot passes the backslashes through with no changes.00 0. Since no end point is given.5 sin(x) 0 −0. the tics continue to the right edge.2f$" set title ’This is $\sin(x)$’ set xlabel "This is the $x$ axis" set ylabel "$\\sin(x)$" unset key set xtics -pi. Finally. The style impulses draws a perpendicular from each point to the x-axis.4 4 There is a style called points that only plots the symbols at data points. This is demonstrated by the following example. pi/4 plot [-pi:pi] [-1:1] sin(x) This is sin(x) 1 0.36 −1. shown in Figure 4. Within single quotes. set terminal latex set output "eg4. the plot can look even better. and changed the format to restrict the x-axis tic labels to 2 decimal places.79 0. the backslash (\).

1 A Summary — Use with L TEX A In summary.\ ’$\frac{\pi}{2}$’ pi/2.1f\mu$’ set title "This is a title" set xlabel "This is the $x$ axis" set ylabel ’This is\\a longer\\version\\ of\\the $y$\\ axis’ offset -1 set label "Data" at -5.7 set key top left set xtic -10. You may ﬁnd documentation for the various commands in the gnuplot manual. 3.5 −1 −π −π 2 0 This is the x axis π 2 π Figure 5: A fancy example of the set xtics command. A Going further: You should now be able to make a variety of plots for your L TEX document.5 sin(x) 0 −0. set terminal latex size 5.-5 right set arrow from -5. the ﬁrst command to gnuplot should be set terminal latex and the output of gnuplot should be directed to a ﬁle.\ 3*exp(-x*x)+1 title ’$3e^{-x^{2}}+1$’ with lines lt 4 Line and point types: For reference.dat" title "Data File" with linespoints lt 1 pt 7. set output "plot.\ ’$\pi$’ pi) This is sin(x) 1 0. to use the most basic L TEX mode of gnuplot.tex" .-5 to -3. though hopefully this example is somewhat self-explanatory. for example.5.3.A Gnuplot L TEX Tutorial Version 4. we show all of the line and point types available in Figure 8. This is shown in Figure 6. 2.-6.4 5 "0" 0.tex" set format y "$%g$" set format x ’$%5.0.10 plot [-10:10] [-10:10] "eg3.0 set output "eg6. We will present a ﬁnal example without explanation that showcases some of the capabilities of gnuplot.

tex ﬁle will be smaller. . the ﬁle will contain all of the plots you have speciﬁed (you probably only want one plot per ﬁle).A Gnuplot L TEX Tutorial Version 4. The quality of the output is about the same.0µ 10. To use EEPIC.4 6 This is a title 10 Data2 File 3e−x + 1 5 This is a longer version 0 of the y axis −5 • • −10 −10. and set clip.tex in your document as before. and use gnuplot as before.0µ 0. 5cm Then you do the (s)plot. and the dvi ﬁle will be smaller. then you can save L TEX memory. set key.. 3 Use with EEPIC A EEPIC is a macro package extending the picture environment of L TEX. L TEX will run much faster (and need much less memory). along with the document style options [epic. If you have the EPIC or EEPIC A macros. set gnuplot’s terminal type to eepic instead of latex. of course. The line styles will change. If you change the source. Include the ﬁle plot.0µ This is the x axis 5. the plot.tex extension. and your dvi translator supports the tpic \specials.eepic].0µ • • • • • • • • • • • • • • Data • • j • • • • −5.g. e. You will also want to read about the following commands: set title. \begin {figure} \begin{center} \input{plot} \end{center} \end {figure} This puts the plot into a ﬁgure. With A EEPIC pictures. and ﬁnally issue commands to close the ﬁle and switch the terminal back to the default by set output set terminal pop Finally. you can generate some more interesting line styles. The default plot size is 5 inches by 3 inches. A This ﬁle can then be used in a L TEX document. set label. set xtics.0µ Figure 6: An example of many features. These are all described in the regular gnuplot manual. set ylabel. set ytics. You can change this be specifying a size in either cm or inches when you select the terminal set terminal latex size 7cm. This may be anything you like but it should have a . set xlabel.

net is where you can send your e-mail.y.15.. or put the entire label in a \parbox. one for the eps A A part of the ﬁgure and one for the L TEX part. the labels in Figure 7 were generated with the following commands: x=.gnuplot.0 A In addition to the latex terminal..65. y=y-dy x. y=. or you can use gnuplot newsgroup comp. For example. The name of the L TEX ﬁle is taken from the ‘set output‘ command.A Gnuplot L TEX Tutorial Version 4.graphics.y u+\fr\ x. The plot can use either color or grayscale. . With the epslatex terminal you cannot use “\\” in a plain string to denote newline. The gnuplot documentation contains more information about the options and usage for each of these. y=.apps.05 set label "left torus:" set label ’$x=\cos u+\frac{1}{2}\cos u \cos v$’ set label ’$y=\sin u+\frac{1}{2}\sin u \cos v$’ set label "$z=\\frac{1}{2}\\sin v$" x=.} command. See the example below. 5 A What is new for TEX and L TEX terminals in gnuplot 4. You can either put each line in a separate label and specify vertical spacing manually.5in}{right torus:\\$x=1+\cos ac{1}{2}\cos u \cos v$\\$y=\frac{1}{2}\sin v$\\\ $z=\sin u + \frac{1}{2}\sin u \cos v$}’ at screen at at at at screen screen screen screen x.gnuplot..tex”) with “. dy=.eps” instead. 6 Sample of epslatex terminal driver The epslatex terminal driver allows you to mix the best features of TEX and PostScript. • mf and mp: Produces metafont and metapost outputs. Text elements are typeset by TEX while the graphic elements are created and positioned in parallel by gnuplot’s PostScript driver.08 set label ’\parbox{2.y left 7 Contact for help For general gnuplot questions. A • pstex and pslatex: Combined TEX / L TEX and postscript parts for text and lines.4 • pslatex and epslatex: Rewritten version. The resulting . with the postscript part included by \includegraphics{. Use of the terminal requires a lua interpreter that is called by gnuplot. the gnuplot mailing list info-gnuplot@lists. A • tikz: Much improved graphics compaired to earlier L TEXterminals.sourceforge. y=y-dy x.} command.tex ﬁle can be processed using pdﬂatex.. • emtex: Like the latex terminal. Addional sources of information are available on gnuplot homepage www. the following L TEX-friendly terminals are available.y.y.info.10.4 7 4 A What is new for TEX and L TEX terminals in gnuplot 4. A • epslatex: Combined L TEX and postscript parts for text and lines. y=y-dy x. The name of the eps ﬁle is derived by replacing the ﬁle extension (normally “. respectively. but supports emtex specials: any line slopes contrary to a very limited A set of L TEX slopes. The driver produces two diﬀerent ﬁles. included by \special{psfile=. respectively.

drawn using the epslatex driver.A Gnuplot L TEX Tutorial Version 4.5 1 0.5 0 -0.5 left torus: x = cos u + 1 cos u cos v 2 y = sin u + 1 sin u cos v 2 z = 1 sin v 2 right torus: x = 1 + cos u + 1 cos u cos v 2 y = 1 sin v 2 1 z = sin u + 2 sin u cos v Figure 7: Interlocking tori demo. .5 -1 -1. -1 0 1 2 left justiﬁed 3 centre+d text 4 right justiﬁed 5 6 7 test of character width: 8 rotated rotated -45 deg rotated ce+ntred text byby +45 deg 12345678901234567890 9 10 11 T 12 d 13 linewidth 14 d ' d E lw 6 15 d lw 5 pattern ﬁll 16 d lw 4 d 0 1 2 3 4 5 6 7 8 9 17 lw 3 c 18 lw 2 lw 1 show ticscale No ﬁlled polygons latex terminal test + × ∗ 2 ◦ • ♦ ♥ ♠ + × ∗ Figure 8: The line and point types available depend on the exact terminal type.PM3D surface with depth sorting 1.4 8 Interlocking Tori .

- Module 4Uploaded byVarghese Thomas E
- latex2e.pdfUploaded byCasco6
- Mathematics Latex GuideUploaded byKSN
- LaTeX Help BeginnerUploaded byjamesyu
- floatfltUploaded byapi-3735277
- Latex Nec CseUploaded byD.KESAVARAJA
- LaTeX2e for Class and Package WritersUploaded byJeff Pratt
- endnotes.pdfUploaded byJoséL.VerçosaMarques
- Draft ConferenceUploaded byTushar Kakkar
- (Tex eBook) - Advanced LatexUploaded byKassala Halnga
- Function-Blocks-Overview-CENTUM-VP.pdfUploaded byramesh
- empheq packageUploaded bymemfilmat
- PLC Scan.pptxUploaded bymoney_kandan2004
- Lec01 Intro CSCI C++Uploaded byPeter
- Omron Plc & Remote Io - Cat2014Uploaded byAwidhi Kresnawan
- 2 Example of Design stage – Video Library part 1Uploaded bysyeqahz
- Twin Cat Module 1Uploaded byjack_tuxford
- cp1e_p061-e1_14_1_csm2118Uploaded byHery Kiswanto
- Et200m Im 153 2 Product Info en en-USUploaded byZhang Jing
- DSQFM-TRX-2Uploaded byAlex Hill
- R500 and EPKS DifferencesUploaded bytricky777
- Siemens - S7-1200 Easy BookUploaded bylaurana123
- 62760 EnUploaded byNica Bogdan

- image_processingUploaded byTejaSatwik
- Storage Manager User Guide SP2Uploaded byplanetsridhar
- High Dimensional Data Clustering Based On Feature Selection AlgorithmUploaded byIJCERT PUBLICATIONS
- Cs6502 Object Oriented Analysis and Design SyllabusUploaded byAswini Jayaraman
- Demystifying-Solution-Manager-7.1-–-configuration-focus-on-diagnostics-Roland-Hoeller-SAP.pdfUploaded byJames Zhu
- computer science XIIUploaded byjamna vyas
- Oracle - problems with DPDK from a user perspective (2016)Uploaded byprashrock
- Binary Representation of Numeric ValuesUploaded byНывпРони
- TutorialUploaded bykumar
- AlignmentUploaded bySathish Kumar
- Energy Efficient CloudUploaded byvj4249
- R28.1 TNM-DNA-M Server Administration Operations GuideUploaded byWaqas Ali Khan
- Razvan Ciobotariu Traning CANoe 07-APR-2016Uploaded byAnonymous 7ixcBT
- JBoss Enterprise SOA Platform-5-JBPM Reference Guide-En-USUploaded byBarbara De Vido
- Design of FPGA Based Encryption Algorithm using KECCAK Hashing FunctionsUploaded byseventhsensegroup
- Itt Training Model T Paper - CopyUploaded byHarun Raaj Gupta
- SAP.Passit4sure.C_TAW12_731.v2015-03-12.by.Clem.80qUploaded byAnonymous XL7jdO8D
- Opencv TutorialsUploaded byMarcos Felipe
- 16364_BigOhUploaded bySapan Anand
- Database Quiz QuestionsUploaded byKITTY ARORA
- ERPNext on Debian 9Uploaded byvecoreda5493
- Digital Electronics_Crack SeriesUploaded bydeepanece
- Getting Started HANAexpress Binary InstallerUploaded byPedro Tenorio
- dp_s01_l03_tryUploaded byCarlos Chu
- MISys Installation Guide 6-4-2018Uploaded bykkozak99
- ICT-AL-2016-E_I_web_p.pdfUploaded byRafeekIrshad
- communicationgfk2220aUploaded byvishart
- Msinfo32 SaleenUploaded byjohnnie_carson4993
- SQA&TUploaded bySharat Ram
- Veyon Admin ManualUploaded byFariz Abdurakhman