Download presentation
Presentation is loading. Please wait.
Published byAlexander Lamb Modified over 8 years ago
1
Learn Gnuplot in an Hour Free and Open Software How to Plot Practically Anything Practically Anyway
2
What is Gnuplot? ● Plotting Software – command-line based ● Unix / Linux ● Mac OS X ● Windows Dialog Box Data Functions
3
Why Gnuplot? ● Fun – Had To Be Fun ● All Common Graphic Formats - jpg, gif, png (and some not so common) ● Readily Available ● Reliable ● Free – Now and Forever ● No Initial Learning Curve
4
The Most Common Commands ● Set (unset reset) ● Plot (replot splot) ● Call ● Help ● History ● Load Usage 90 % ● Print ● Save ● Show ● Test
5
What We're Going to Do (1 of 2) Interactive Mode ● Plot Functions ● Line Width and Line Type ● Set ● X- and Y- Labels / Ranges ● Grid ● Title ● Key (legend) ● Save and Load Files (by the book) ● Save Files (by hook-or-by-crook) History Command
6
What We're Going to Do (2 of 2) 'Scriptive' Mode ● Plot Data ● Data Format / Separators ● Line Width and Line Type (revisited) ● Test Command ● Terminals ● Export Graphs
7
Interactive Mode (1 of 10) Begin at the Beginning ● Open a Terminal ● cd Desktop ● gnuplot G N U P L O T Version 4.4 patchlevel 0 last modified March 2010 System: Linux 2.6.28-19-generic Copyright (C) 1986-1993, 1998, 2004, 2007- 2010 Thomas Williams, Colin Kelley and many others gnuplot home: http://www.gnuplot.info faq, bugs, etc: type "help seeking- assistance" immediate help: type "help" plot window: hit 'h' Terminal type set to 'x11' gnuplot> Version 4.4 ?
8
Interactive Mode (2 of 10) Your first plot! ● gnuplot> plot sin(x)
9
Interactive Mode (3 of 10) Modify the Ranges: x and y ● gnuplot> plot [-6:6] [-1.25:1.25] sin(x)
10
Interactive Mode (4 of 10) Modify the Grid and Title ● gnuplot>set grid ● gnuplot>set title 'Sinusoids' ● gnuplot> replot
11
Interactive Mode (5 of 10) Modify the X-Label and Y-Label ● gnuplot>set xlabel 'X-Values' ● gnuplot>set ylabel 'Amplitude' ● gnuplot> replot
12
Interactive Mode (6 of 10) Add a 2 nd Function ● gnuplot>plot [-6:6] [-1.25:1.25] sin(x), cos(x) Don't forget the comma.
13
Interactive Mode (7 of 10) Modify the Plot Command - Width ● gnuplot>plot [-6:6] [-1.25:1.25] sin(x) linewidth 3, cos(x) linewidth 3 Change the width of the lines.
14
Interactive Mode (8 of 10) Modify the Plot Command - Color ● gnuplot>plot [-6:6] [-1.25:1.25] sin(x) linetype 1 linewidth 3, cos(x) linetype 3 linewidth 3
15
Interactive Mode (9 of 10) Modify the Plot Command - Key ● gnuplot>plot [-6:6] [-1.25:1.25] sin(x) linetype 1 linewidth 3 title "Sin", cos(x) linetype 3 linewidth 3 title "Cos"
16
Interactive Mode (1 of 2) Save and Load –.gp files (.plt Windows) ● gnuplot> save 'temp.gp' ● gnuplot > load 'temp.gp' ● Open 'temp.gp' In gedit – (OMG) Save your work. Load and run your work. ● gnuplot> show all Details Galore!.
17
Interactive Mode (2 of 2) The History Command ● gnuplot> history quiet What happened? set grid set xlabel "X-Values" set ylabel "Amplitude" set title "Sinusoids" plot [0:6.28] [-1.6:1.6] sin(x) with lines linewidth 4 title "Sin", cos(x) with lines linewidth 4 title "Cos" history quiet Copy and paste into gedit. Remove unwanted lines. Save as 'filename.gp' ● gnuplot> history
18
● Plot Functions ● Line Width and Line Type ● Set ● X- and Y- Labels / Ranges ● Grid ● Title ● Key (legend) ● Save and Load Files (by the book) ● Save Files (History command) Interactive Mode (summary)
19
Scriptive Mode (1 of 9) View the Data ● In gedit open the Sinusoids.dat file # Sinusoids.dat contains white-space separated data -3.14 0 -1 -3.04 -0.1 -0.99 -2.94 -0.2 -0.98 -2.84 -0.3 -0.95 -2.74 -0.39 -0.92 -2.64 -0.48 -0.88 -2.54 -0.57 -0.82 -2.44 -0.65 -0.76 -2.34 -0.72 -0.7 etc.
20
Scriptive Mode (2 of 9) View the gnuplot file ● In gedit open the SinusoidsOne.gp file # SinusoidsOne.gp calls the white-space separated data file set grid # No data separator is necessary in this file. set title "With White-Space Data File" Plot [ ] [-1.75:1.25] "Sinusoids.dat" using 1:2 title "Sin" Calls data file Refers to columns 1 and 2
21
Scriptive Mode (3 of 9) Run the gnuplot file “scriptively” ● Open a terminal ● cd Desktop ● gnuplot -persist 'SinusoidsOne.gp'
22
Scriptive Mode (4 of 9) Modify the gnuplot file to include Lines, Points, Linepoints ● In gedit remark-out the first plot command and run with Points ● In gedit remark-out the first plot command and run with Lines ● In gedit remark-out the first plot command and run with Linespoints
23
Scriptive Mode (5 of 9) View the CSV Data ● In gedit open the Sinusoids.cvs file # Sinusoids.dat contains comma-separated data -3.14,0,-1 -3.04,-0.1,-0.99 -2.94,-0.2,-0.98 -2.84,-0.3,-0.95 -2.74,-0.39,-0.92 -2.64,-0.48,-0.88 -2.54,-0.57,-0.82 -2.44,-0.65,-0.76 etc.
24
Scriptive Mode (6 of 9) View the gnuplot file ● In gedit open the SinusoidsTwo.gp file # SinusoidsTwo.gp calls the CSV separated data file set grid set datafile separator "," # To accommodate the commas in the data file. set title "With CSV Data File" Plot [ ] [-1.75:1.25] "Sinusoids.csv" using 1:2 title "Sin” Calls data file Refers to columns 1 and 2
25
Scriptive Mode (7 of 9) Modify the gnuplot file to include Lines, Points, Linepoints ● In gedit remark-out the first plot command and run with either Points, Lines or Linespoints
26
Scriptive Mode (8 of 9) Add a 2 nd and 3 rd Function ● In gedit open SinusoidsThree.gp ● gnuplot -persist 'SinusoidsThree.gp' ● Review plot command in file Note type and size of curves: Lines, Points and a combination.
27
Scriptive Mode (9 of 9) Review of SinusoidsThree.gp # SinusoidsThree.gp uses a mathematical formula – 'data transformation' # And used "lines" for the Sin, "Points" for Cos and "Linespoint" for the Difference. set grid set title "Notice!! Sin in Lines \nCos in Points \n Difference in Linespoints." Plot [ ] [-1.75:1.75] "Sinusoids.dat" using 1:2 with lines linetype 1 title "Sin", \ "Sinusoids.dat" using 1:3 with points pointsize 2 linetype 3 title "Cos", \ "Sinusoids.dat" using 1:($2 -$3) with linespoints linewidth 2 linetype 6 title "Sin - Cos" # Note difference: Lines, Points and Linespoints # Note different Line and Point Sizes # Remember can change x-range for better view of Points and Lines # Note also the formula: using 1:($2-$3)
28
Test Command Reviewing Color and Linetype ● In gnuplot type gnuplot>test ● Open Test.GIF by double clicking on it ● Compare them
29
Terminals (1 of 2) ● In gnuplot type: gnuplot>show terminal ● In gnuplot type: gnuplot>set terminal gif ● In gnuplot type: gnuplot>show terminal ● In gnuplot type: gnuplot>set terminal x11 ● Some Terminals: gif, png, jpg, svg, ps (re: LaTeX) Set terminal back to original setting
30
Terminals (2 of 2) GIF Example ● In gedit open SinusoidsGIF.gp ● Review SinusoidsGIF.gp ● gnuplot SinusoidsGIF.gp SinusoidsGIF.gp includes: set terminal gif set output
31
● Plot Data ● Data Format / Separators ● Line Width and Line Type (revisited) ● Test Command ● Terminals ● Export Graphs Interactive Mode (summary)
32
What's Ahead Some Topics Not Covered ● Abbreviations ● Animation ● Arrows and Labels ● Colors (4 other methods) ● Fonts ● Data Smoothing ● Help ● Macros ● Missing Data ● Multi-plots ● Numerical Formats ● Polar Coordinates ● Redirection ● Statistics ● Size and Ratio ● Time Series
33
Websites for Follow-up ● Gnuplot Home Page http://www.gnuplot.info/ http://www.gnuplot.info/ ● Gnuplot Demo Pages http://gnuplot.sourceforge.net/demo_4.2/ http://gnuplot.sourceforge.net/demo_4.4/ http://gnuplot.sourceforge.net/demo_4.2/ http://gnuplot.sourceforge.net/demo_4.4/ ● Demo of Demo Pages copy, paste and run Demo_4.4/histograms in gnuplot copy, paste and run Demo_4.4/control models in gnuplot (adjust x-range 0 to 10 and y-range 0 to 1.8) copy, paste and run Demo_4.4/finance in gnuplot
34
Additional Websites, etc. ● Gnuplot Newsgroup comp.graphics.apps.gnuplot ● Gnuplot mailing list gnuplot-info@lists.sourceforge.net ● More Advanced gnuplot info http://t16web.lanl.gov/Kawano/gnuplot/index-e.html http://t16web.lanl.gov/Kawano/gnuplot/index-e.html ● gnuplot_QuickReference.pdf
35
The End ! Thank You
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.