SlideShare a Scribd company logo
1 of 18
Download to read offline
GNUPLOT
Dr. Farkhanda Ana
Assistant Professor
Dept. of ECE
SoET, Baba Ghulam Shah Badshah University
Rajouri, J&K
Basics
• Gnuplot was originally developed by Colin Kelley and Thomas Williams in 1986 to plot
functions and data files on a variety of terminals.
• GNUPLOT is a freely distributed command-line based interactive plotting program.
 installing GNUPLOT
Windows get .exe from sourceforge.net/projects/gnuplot/files
Mac get .tar.gz from sourceforge.net/projects/gnuplot/files
open shell, go to download directory, type ”configure”, ”make”,”sudo make install”
Linux use package management system
• starting GNUPLOT
Windows GUI
Linux, Mac open shell, type ”gnuplot”
• closing GNUPLOT
Windows GUI
Linux, Mac type ”exit” or ”quit”
Starting Gnuplot
• Go to a command line.
• Start gnuplot by typing gnuplot.
• Check gnuplot version and patch level .
• Check which terminals have been installed by typing set terminal. At least
terminals wxt, png, latex and tikz must be installed.
• check your current terminal by typing show terminal.
• type test, gnuplot will show the line types and point types available for current
terminal type.
• Check if ImageMagick is installed by typing !convert
Gnuplot syntax basics
• GNUPLOT can display the manuals for its commands
e.g. type help plot to get information on the plot command
• Commands can be shortened
e.g. rep instead of replot or p instead of plot
• Reset restores the defaults
• If we want to use more than one GNUPLOT command in one line, separate the
commands by ;
• GNUPLOT comments start with #
• Shell commands (e.g. vi) in GNUPLOT start with !
• File names have to be enclosed in single or double quotes
• To plot a sine curve open gnuplot and type
• f(x) = sin(x) # define a function
• plot f(x) # plot this function
• replot f(2*x) # plot another function
• GNUPLOT will open a window with plot.
• The curves will not look smooth.
• Fix this by increasing the sampling rate:
• set samples 200 # sampling rate
• set ytics 0.5; set mytics 5
• set xrange [-pi:pi] # x range
• set xtics ("-pi" -pi, "-pi/2" -pi/2, 0, "pi/2"
pi/2, "pi" pi)
Scripting
• Powerful tool of gnuplot.
• Scripts can be written in any word editor.
• Script files can be run in gnuplot by typing:
Load ‘myscript.txt’
• But proper path has to be given if script file is not in current directory.
• Data can be generated in tabular form for a function plotted in
gnuplot.
• Type set table “tablefile.txt”
Plot f(x)
Unset table
Myscript.txt
• set term wxt # s e l e c t di splay type
• set ytics 0.5 # def ine distance of labeled t i c k marks on the y−axis
• set mytics 5 # number of small t i c k marks on the y−axis
• set xrange [−p i : p i ] # set x range of the p l o t
• set xtics ( ”−p i ” −pi , ”−p i /2 ” −p i /2 ,0 , ” p i /2 ” p i /2 , ” p i ” p i )
# custom l a b e l s
• set samples 200 # increase sampling rate
• set key at −p i /8 ,0.8 i n v e r t samplen 2 # place and format key of symbols
• f ( x ) = sin ( x ) # def ine a f u n c t i o n
• plot f ( x ) t “s in ( x ) ” , f (2x ) t “ s in (2 x ) ” # p l o t two f un c t i on s
• pause −1 ” h i t ENTER to e x i t s c r i p t ” # don ’ t close gnuplot
Plotting data
• Gnuplot can read data from files
• scatter plot:
plot ’tablefile1.txt’ using 1:2 with points
• line plot:
plot ’tablefile1.txt’ using 1:2 with lines
• multiple data series:
use replot or separate by commas
• set key:
plot ’tablefile1.txt’ using 1:2 title "key“
• Parametric plot
set parametric
set trange [-pi:pi]
plot sin(t),cos(t)
unset parametric
( In the parametric mode, the variable is “t”)
Labels, arrows, keys
• place or hide key
set key top center, set nokey
• set a title
set title "the title"
• define axis labels
set xlabel "x [pc]", set ylabel "y [pc]"
• change the number format
set format x "%10.3f"
• plot an arrow
set arrow from 0.5,0 to 0.5,1
• define a label
set label "rarefaction wave" at 0.5,0
• set border style
set border lw 3
Polar plot and multiplot
• If you want to draw a rosette shaped curve you can use:
set polar
set size square
f(t)=a*sin(b*t)
a=2
b=2
plot f(t)
unset polar
• In the parametric mode, the variable is “t” (instead of x).
set multiplot
set origin 0 ,0
set size 0.5 ,0.5
plot x*x*x t ‘x ˆ3 ”
set origin 0 ,0.5
Plot x t ”x ”
set origin 0.5 ,0.5
plot x*x t ‘x ˆ2 ”
set origin 0.5 ,0
plot x*x*x*x t ”x ˆ4 ”
unset mu l t i p l o t
Fitting data
Output formats
• Set terminal png, latex, wxt..
set terminal png
set output "plot.png"
set multiplot
...
unset multiplot
set term wxt
Gnuplot and latex
• To use the most basic LATEX mode of gnuplot, the first command to
gnuplot should be:
 set terminal latex
• and the output of gnuplot should be directed to a file, for example,
 set output "plot.tex“
• The default plot size is 5 inches by 3 inches.
• It can be changed by specifying a size in either cm or inches when you
select the terminal
 set terminal latex size 7cm, 5cm
 Then (s)plot, and issue commands to close the file and switch the terminal
back to the default by
 ,
Contd.
• set output
• set terminal wxt
• Finally, the file will contain all of the plots specified (probably want one
plot per file).
set terminal latex
set output "eg4.tex"
set format y "$%g$"
set format x "$%.2f$"
set title 'This is $sin(x)$'
set xlabel "This is the $x$ axis"
set ylabel "$sin(x)$"
unset key
set xtics -pi, pi/4
plot [-pi:pi] [-1:1] sin(x)
Contd.
• This file can then be used in a LATEX document,
begin {figure}
begin{center}
input{plot}
end{center}
end {figure}
Use with EEPIC
• EEPIC is a macro package extending the picture environment of LATEX.
• with EPIC or EEPIC macros, one can save LATEX memory.
• With EEPIC pictures, the plot.tex file will be smaller, LATEX will run
much faster (and need much less memory),
• the dvi file will be smaller.
• The quality of the output is about the same.
• To use EEPIC, set gnuplot's terminal type to eepic instead of latex, and use
gnuplot as before.
• The line styles will change.
• Include the file plot.tex in your document as before, along with the
document style
• options [epic,eepic].
Other TEX-based terminal types in gnuplot
• emtex: Like the latex terminal, but supports emtex specials: any line slopes
contrary to a very limited set of LATEX slopes.
• epslatex: Combined LATEX and postscript parts for text and lines,
respectively, with the postscript part included by includegraphics{...}
command.
• pstex and pslatex: Combined TEX/LATEX and postscript parts for text and
lines, respectively, included by special{psfile=...} command.
• mf and mp: Produces metafont and metapost outputs.
• pslatex and epslatex: New versions of these terminals were introduced in
gnuplot 4.4.
• tikz: Much improved graphics compared to earlier LATEX terminals.
• Use of the terminal requires a lua interpreter that is called by gnuplot.
• The resulting .tex file can be processed using pdatex.
• context: Produces output for the context environment.

More Related Content

What's hot

Dynamic Memory allocation
Dynamic Memory allocationDynamic Memory allocation
Dynamic Memory allocationGrishma Rajput
 
Tcl2012 8.6 Changes
Tcl2012 8.6 ChangesTcl2012 8.6 Changes
Tcl2012 8.6 Changeshobbs
 
Introduction to matplotlib
Introduction to matplotlibIntroduction to matplotlib
Introduction to matplotlibPiyush rai
 
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)Sylvain Hallé
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocationNaveen Gupta
 
Fl0ppy - CODEGATE 2016 CTF Preliminary
Fl0ppy - CODEGATE 2016 CTF PreliminaryFl0ppy - CODEGATE 2016 CTF Preliminary
Fl0ppy - CODEGATE 2016 CTF PreliminaryYOKARO-MON
 
BeepBeep 3: A declarative event stream query engine (EDOC 2015)
BeepBeep 3: A declarative event stream query engine (EDOC 2015)BeepBeep 3: A declarative event stream query engine (EDOC 2015)
BeepBeep 3: A declarative event stream query engine (EDOC 2015)Sylvain Hallé
 
2013 april gruff webinar san diego copy
2013 april  gruff webinar   san diego copy2013 april  gruff webinar   san diego copy
2013 april gruff webinar san diego copyBarbaraStarr2009
 
2013 april gruff webinar san diego copy
2013 april  gruff webinar   san diego copy2013 april  gruff webinar   san diego copy
2013 april gruff webinar san diego copyBarbaraStarr2009
 
Exploring slides
Exploring slidesExploring slides
Exploring slidesakaptur
 
Malloc() and calloc() in c
Malloc() and calloc() in cMalloc() and calloc() in c
Malloc() and calloc() in cMahesh Tibrewal
 
Matplotlib 簡介與使用
Matplotlib 簡介與使用Matplotlib 簡介與使用
Matplotlib 簡介與使用Vic Yang
 
Intoduction to dynamic memory allocation
Intoduction to dynamic memory allocationIntoduction to dynamic memory allocation
Intoduction to dynamic memory allocationUtsav276
 
Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Sylvain Hallé
 

What's hot (20)

Dynamic Memory allocation
Dynamic Memory allocationDynamic Memory allocation
Dynamic Memory allocation
 
Tcl2012 8.6 Changes
Tcl2012 8.6 ChangesTcl2012 8.6 Changes
Tcl2012 8.6 Changes
 
Stack and heap
Stack and heapStack and heap
Stack and heap
 
Introduction to matplotlib
Introduction to matplotlibIntroduction to matplotlib
Introduction to matplotlib
 
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
A "Do-It-Yourself" Specification Language with BeepBeep 3 (Talk @ Dagstuhl 2017)
 
Dynamic memory allocation
Dynamic memory allocationDynamic memory allocation
Dynamic memory allocation
 
Fl0ppy - CODEGATE 2016 CTF Preliminary
Fl0ppy - CODEGATE 2016 CTF PreliminaryFl0ppy - CODEGATE 2016 CTF Preliminary
Fl0ppy - CODEGATE 2016 CTF Preliminary
 
Stack queue
Stack queueStack queue
Stack queue
 
NUMPY
NUMPY NUMPY
NUMPY
 
BeepBeep 3: A declarative event stream query engine (EDOC 2015)
BeepBeep 3: A declarative event stream query engine (EDOC 2015)BeepBeep 3: A declarative event stream query engine (EDOC 2015)
BeepBeep 3: A declarative event stream query engine (EDOC 2015)
 
2013 april gruff webinar san diego copy
2013 april  gruff webinar   san diego copy2013 april  gruff webinar   san diego copy
2013 april gruff webinar san diego copy
 
2013 april gruff webinar san diego copy
2013 april  gruff webinar   san diego copy2013 april  gruff webinar   san diego copy
2013 april gruff webinar san diego copy
 
Stacks
StacksStacks
Stacks
 
Exploring slides
Exploring slidesExploring slides
Exploring slides
 
Malloc() and calloc() in c
Malloc() and calloc() in cMalloc() and calloc() in c
Malloc() and calloc() in c
 
Matplotlib 簡介與使用
Matplotlib 簡介與使用Matplotlib 簡介與使用
Matplotlib 簡介與使用
 
Faster Python, FOSDEM
Faster Python, FOSDEMFaster Python, FOSDEM
Faster Python, FOSDEM
 
Intoduction to dynamic memory allocation
Intoduction to dynamic memory allocationIntoduction to dynamic memory allocation
Intoduction to dynamic memory allocation
 
Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings Activity Recognition Through Complex Event Processing: First Findings
Activity Recognition Through Complex Event Processing: First Findings
 
Python Scipy Numpy
Python Scipy NumpyPython Scipy Numpy
Python Scipy Numpy
 

Similar to Gnuplot 2

Gráficas en python
Gráficas en python Gráficas en python
Gráficas en python Jhon Valle
 
PPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.TechPPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.Techssuser2678ab
 
Lecture1_cis4930.pdf
Lecture1_cis4930.pdfLecture1_cis4930.pdf
Lecture1_cis4930.pdfzertash1
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manualSami Said
 
Cs4hs2008 track a-programming
Cs4hs2008 track a-programmingCs4hs2008 track a-programming
Cs4hs2008 track a-programmingRashi Agarwal
 
Python 3.6 Features 20161207
Python 3.6 Features 20161207Python 3.6 Features 20161207
Python 3.6 Features 20161207Jay Coskey
 
Python GTK (Hacking Camp)
Python GTK (Hacking Camp)Python GTK (Hacking Camp)
Python GTK (Hacking Camp)Yuren Ju
 
Python-GTK
Python-GTKPython-GTK
Python-GTKYuren Ju
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboyKenneth Geisshirt
 
INTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxINTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxNimrahafzal1
 
Introduction to Python Programming .pptx
Introduction to Python Programming .pptxIntroduction to Python Programming .pptx
Introduction to Python Programming .pptxtilakrajpanchal22600
 
01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seoJinTaek Seo
 

Similar to Gnuplot 2 (20)

Gráficas en python
Gráficas en python Gráficas en python
Gráficas en python
 
Golang
GolangGolang
Golang
 
PPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.TechPPT on Python - illustrating Python for BBA, B.Tech
PPT on Python - illustrating Python for BBA, B.Tech
 
Lecture1_cis4930.pdf
Lecture1_cis4930.pdfLecture1_cis4930.pdf
Lecture1_cis4930.pdf
 
iPython
iPythoniPython
iPython
 
python_class.pptx
python_class.pptxpython_class.pptx
python_class.pptx
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
 
Cs4hs2008 track a-programming
Cs4hs2008 track a-programmingCs4hs2008 track a-programming
Cs4hs2008 track a-programming
 
Python
PythonPython
Python
 
Python 3.6 Features 20161207
Python 3.6 Features 20161207Python 3.6 Features 20161207
Python 3.6 Features 20161207
 
Python GTK (Hacking Camp)
Python GTK (Hacking Camp)Python GTK (Hacking Camp)
Python GTK (Hacking Camp)
 
Python ppt
Python pptPython ppt
Python ppt
 
Python-GTK
Python-GTKPython-GTK
Python-GTK
 
Perl Programming - 01 Basic Perl
Perl Programming - 01 Basic PerlPerl Programming - 01 Basic Perl
Perl Programming - 01 Basic Perl
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Cc code cards
Cc code cardsCc code cards
Cc code cards
 
Go Lang Tutorial
Go Lang TutorialGo Lang Tutorial
Go Lang Tutorial
 
INTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptxINTRODUCTION TO PYTHON.pptx
INTRODUCTION TO PYTHON.pptx
 
Introduction to Python Programming .pptx
Introduction to Python Programming .pptxIntroduction to Python Programming .pptx
Introduction to Python Programming .pptx
 
01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo01 stack 20160908_jintaek_seo
01 stack 20160908_jintaek_seo
 

Recently uploaded

MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 

Recently uploaded (20)

★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 

Gnuplot 2

  • 1. GNUPLOT Dr. Farkhanda Ana Assistant Professor Dept. of ECE SoET, Baba Ghulam Shah Badshah University Rajouri, J&K
  • 2. Basics • Gnuplot was originally developed by Colin Kelley and Thomas Williams in 1986 to plot functions and data files on a variety of terminals. • GNUPLOT is a freely distributed command-line based interactive plotting program.  installing GNUPLOT Windows get .exe from sourceforge.net/projects/gnuplot/files Mac get .tar.gz from sourceforge.net/projects/gnuplot/files open shell, go to download directory, type ”configure”, ”make”,”sudo make install” Linux use package management system • starting GNUPLOT Windows GUI Linux, Mac open shell, type ”gnuplot” • closing GNUPLOT Windows GUI Linux, Mac type ”exit” or ”quit”
  • 3. Starting Gnuplot • Go to a command line. • Start gnuplot by typing gnuplot. • Check gnuplot version and patch level . • Check which terminals have been installed by typing set terminal. At least terminals wxt, png, latex and tikz must be installed. • check your current terminal by typing show terminal. • type test, gnuplot will show the line types and point types available for current terminal type. • Check if ImageMagick is installed by typing !convert
  • 4. Gnuplot syntax basics • GNUPLOT can display the manuals for its commands e.g. type help plot to get information on the plot command • Commands can be shortened e.g. rep instead of replot or p instead of plot • Reset restores the defaults • If we want to use more than one GNUPLOT command in one line, separate the commands by ; • GNUPLOT comments start with # • Shell commands (e.g. vi) in GNUPLOT start with ! • File names have to be enclosed in single or double quotes
  • 5. • To plot a sine curve open gnuplot and type • f(x) = sin(x) # define a function • plot f(x) # plot this function • replot f(2*x) # plot another function • GNUPLOT will open a window with plot. • The curves will not look smooth. • Fix this by increasing the sampling rate: • set samples 200 # sampling rate • set ytics 0.5; set mytics 5 • set xrange [-pi:pi] # x range • set xtics ("-pi" -pi, "-pi/2" -pi/2, 0, "pi/2" pi/2, "pi" pi)
  • 6. Scripting • Powerful tool of gnuplot. • Scripts can be written in any word editor. • Script files can be run in gnuplot by typing: Load ‘myscript.txt’ • But proper path has to be given if script file is not in current directory. • Data can be generated in tabular form for a function plotted in gnuplot. • Type set table “tablefile.txt” Plot f(x) Unset table
  • 7. Myscript.txt • set term wxt # s e l e c t di splay type • set ytics 0.5 # def ine distance of labeled t i c k marks on the y−axis • set mytics 5 # number of small t i c k marks on the y−axis • set xrange [−p i : p i ] # set x range of the p l o t • set xtics ( ”−p i ” −pi , ”−p i /2 ” −p i /2 ,0 , ” p i /2 ” p i /2 , ” p i ” p i ) # custom l a b e l s • set samples 200 # increase sampling rate • set key at −p i /8 ,0.8 i n v e r t samplen 2 # place and format key of symbols • f ( x ) = sin ( x ) # def ine a f u n c t i o n • plot f ( x ) t “s in ( x ) ” , f (2x ) t “ s in (2 x ) ” # p l o t two f un c t i on s • pause −1 ” h i t ENTER to e x i t s c r i p t ” # don ’ t close gnuplot
  • 8. Plotting data • Gnuplot can read data from files • scatter plot: plot ’tablefile1.txt’ using 1:2 with points • line plot: plot ’tablefile1.txt’ using 1:2 with lines • multiple data series: use replot or separate by commas • set key: plot ’tablefile1.txt’ using 1:2 title "key“ • Parametric plot set parametric set trange [-pi:pi] plot sin(t),cos(t) unset parametric ( In the parametric mode, the variable is “t”)
  • 9. Labels, arrows, keys • place or hide key set key top center, set nokey • set a title set title "the title" • define axis labels set xlabel "x [pc]", set ylabel "y [pc]" • change the number format set format x "%10.3f" • plot an arrow set arrow from 0.5,0 to 0.5,1 • define a label set label "rarefaction wave" at 0.5,0 • set border style set border lw 3
  • 10. Polar plot and multiplot • If you want to draw a rosette shaped curve you can use: set polar set size square f(t)=a*sin(b*t) a=2 b=2 plot f(t) unset polar • In the parametric mode, the variable is “t” (instead of x). set multiplot set origin 0 ,0 set size 0.5 ,0.5 plot x*x*x t ‘x ˆ3 ” set origin 0 ,0.5 Plot x t ”x ” set origin 0.5 ,0.5 plot x*x t ‘x ˆ2 ” set origin 0.5 ,0 plot x*x*x*x t ”x ˆ4 ” unset mu l t i p l o t
  • 12. Output formats • Set terminal png, latex, wxt.. set terminal png set output "plot.png" set multiplot ... unset multiplot set term wxt
  • 13. Gnuplot and latex • To use the most basic LATEX mode of gnuplot, the first command to gnuplot should be:  set terminal latex • and the output of gnuplot should be directed to a file, for example,  set output "plot.tex“ • The default plot size is 5 inches by 3 inches. • It can be changed by specifying a size in either cm or inches when you select the terminal  set terminal latex size 7cm, 5cm  Then (s)plot, and issue commands to close the file and switch the terminal back to the default by  ,
  • 14. Contd. • set output • set terminal wxt • Finally, the file will contain all of the plots specified (probably want one plot per file). set terminal latex set output "eg4.tex" set format y "$%g$" set format x "$%.2f$" set title 'This is $sin(x)$' set xlabel "This is the $x$ axis" set ylabel "$sin(x)$" unset key set xtics -pi, pi/4 plot [-pi:pi] [-1:1] sin(x)
  • 15. Contd. • This file can then be used in a LATEX document, begin {figure} begin{center} input{plot} end{center} end {figure}
  • 16. Use with EEPIC • EEPIC is a macro package extending the picture environment of LATEX. • with EPIC or EEPIC macros, one can save LATEX memory. • With EEPIC pictures, the plot.tex file will be smaller, LATEX will run much faster (and need much less memory), • the dvi file will be smaller. • The quality of the output is about the same. • To use EEPIC, set gnuplot's terminal type to eepic instead of latex, and use gnuplot as before. • The line styles will change. • Include the file plot.tex in your document as before, along with the document style • options [epic,eepic].
  • 17. Other TEX-based terminal types in gnuplot • emtex: Like the latex terminal, but supports emtex specials: any line slopes contrary to a very limited set of LATEX slopes. • epslatex: Combined LATEX and postscript parts for text and lines, respectively, with the postscript part included by includegraphics{...} command. • pstex and pslatex: Combined TEX/LATEX and postscript parts for text and lines, respectively, included by special{psfile=...} command. • mf and mp: Produces metafont and metapost outputs. • pslatex and epslatex: New versions of these terminals were introduced in gnuplot 4.4.
  • 18. • tikz: Much improved graphics compared to earlier LATEX terminals. • Use of the terminal requires a lua interpreter that is called by gnuplot. • The resulting .tex file can be processed using pdatex. • context: Produces output for the context environment.