Using GNUPlot on LONI Resources B. Estrade. Objectives ● learn to use many features of gnuplot, including: – simple plotting – 3d plotting – working with.

Slides:



Advertisements
Similar presentations
Lab # 03- SS Basic Graphic Commands. Lab Objectives: To understand M-files principle. To plot multiple plots on a single graph. To use different parameters.
Advertisements

Introduction to Graphing Using MATLAB. Line Graphs  Useful for graphing functions  Useful for displaying data trends over time  Useful for showing.
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
Welcome to E-Prime E-Prime refers to the Experimenter’s Prime (best) development studio for the creation of computerized behavioral research. E-Prime is.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Intro to ArcMap Customization with Visual Basic  Create your own toolbars, buttons, interactive tools, and programs  Runs behind the scenes in ArcMap.
EGR106 Week 6 MATLAB FILES Two Dimensional Plots Multiple Plots
REVITALISE Visualization Tools Overview: gnuplot Garrett Love Shodor Education Foundation Durham, NC.
ArcView and GMT – An Introduction to Two Simple GIS Systems Bill Langin EAS 781 9/18/02.
IS&T Scientific Visualization Tutorial – Spring 2010 Robert Putnam Plotting packages overview.
CSE4251 The Unix Programming Environment
1 A Portable Scientific Visualization Program: GnuPlot Asst. Prof. Emin Korkut.
Introduction to UNIX/Linux Exercises Dan Stanzione.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
GUI development with Matlab: GUI Front Panel Components 1 GUI front panel components In this section, we will look at -GUI front panel components -Programming.
BINF 634 Fall Lec 11 Visualization1 Plan for Tonight A synopsis of our progress through the course Lecture 11 Visualization in PERL Lab 2 Based.
Gnuplot What is gnuplot? an interactive plotting program.
COMP 116: Introduction to Scientific Programming Lecture 5: Plotting, Scripts and publishing.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
Gnuplot From command line, type gnuplot G N U P L O T Linux version 3.7 patchlevel 1 last modified Fri Oct 22 18:00:00 BST 1999 Copyright(C) ,
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
40 Years and Still Rocking the Terminal!
UW CSE 190p Section 7/26, Summer 2012 Dun-Yu Hsiao.
Lab 3 + Using the Terminal 1. "Under Linux there are GUIs (graphical user interfaces). where you can point and click and drag, and hopefully get work.
EGR 106 Lecture 6 2-D Plotting Graphical presentation has become the standard method to show technical information. Engineers use plots to analyze, visualize,
Intermacs Form Download Excel Tutorial Pivot Tables, Graphic Tools, Macros By: Devin Koehl.
WRITING REPORTS Introduction Section 0 Lecture 1 Slide 1 Lecture 6 Slide 1 INTRODUCTION TO Modern Physics PHYX 2710 Fall 2004 Intermediate 3870 Fall 2015.
Intermacs Form Download Excel Tutorial Pivot Tables, Graphic Tools, Macros By: Devin Koehl.
PTA Linux Series Copyright Professional Training Academy, CSIS, University of Limerick, 2006 © Workshop III - Part A Shell Commands Professional Training.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
Learn Gnuplot in an Hour Free and Open Software How to Plot Practically Anything Practically Anyway.
Introduction to Gnuplot Bob Dowling University Computing Service.
GRID COMPUTING.
UNIX To do work for the class, you will be using the Unix operating system. Once connected to the system, you will be presented with a login screen. Once.
Tutorial of Unix Command & shell scriptS 5027
Development Environment
CST 1101 Problem Solving Using Computers
MATLAB – More Script Files
Prepared by: Eng. Maryam Adel Abdel-Hady
Bash Introduction (adapted from chapters 1 and 2 of bash Cookbook by Albing, Vossing, & Newham) CPTE 440 John Beckett.
Microsoft Excel.
Run-time and off-line visualization support
Computer Fundamentals
Computer Application in Engineering Design
Using Jabber in Global Offices
Lecture 25.
Some Linux Commands.
Part 3 – Remote Connection, File Transfer, Remote Environments
Lecture 25: Exploring data
Shell Script Assignment 1.
Basic operations in Matlab
Outline Matlab tutorial How to start and exit Matlab Matlab basics.
Prepared by Kimberly Sayre and Jinbo Bi
LING 408/508: Computational Techniques for Linguists
Chapter 2 – Introduction to the Visual Studio .NET IDE
MATLAB How to use (using M-files) Double click this icon
Guide To UNIX Using Linux Third Edition
Welcome to E-Prime E-Prime refers to the Experimenter’s Prime (best) development studio for the creation of computerized behavioral research. E-Prime is.
MATLAB How to use (using M-files) Double click this icon
GRAPHICAL USER INTERFACE
MATLAB How to use (using M-files)
Introduction Paul Flynn
Plotting Signals in MATLAB
Chapter 1: Programming Basics, Python History and Program Components
Presentation transcript:

Using GNUPlot on LONI Resources B. Estrade

Objectives ● learn to use many features of gnuplot, including: – simple plotting – 3d plotting – working with data files – automating gnuplot – sources of more information

Note ● much of the material for this presentation was borrowed from the extremely useful and comprehensive gnuplot guide at:

Exercises ● When applicable, I will stop and ask each participant to try an example for themselves

What is gnuplot? ● a fairly complete, free graphing tool ● works on Linux and Windows, among other OSs ● provides interfaces for both interactive and batch plotting ● provides basic 3D plotting capabilities ● best of all, gnuplot is easy

Getting Started ● log into a remote LONI resource, making sure X11 forwarding is enabled qb1.loni.org ● for more info, please see ● start gnuplot interactively by typing “gnuplot” into the shell prompt

The gnuplot Shell ● provides an interactive interface to gnuplot ● provides methods to output plots in various formats ● provides access to underlying user land shell

Non-plotting Commands ● some useful built-in commands – gnuplot> pwd – gnuplot> cd ● to escape to the underlying user land shell, preface the command with an exclamation point; example: – gnuplot> !ls -lart – gnuplot> !cat somefile > someotherfile

Your First Plot uses the plot command

Your Second Plot uses the replot command to retain the 1 st plot

Your Third Plot uses the replot command to retain the 1 st and 2 nd plot

Axis Labels uses the set xlabel and set ylabel commands to label the X and Y axis, respectively

Axis Ranges uses the set xrange and set yrange commands to define the X and Y ranges, respectively

Command Recap (please try) 1)plot sin(x) 2)replot cos(x) 3)replot sin(x)*cos(x) 4)set xlabel “X-LABEL” 5)set ylabel “Y-LABEL” 6)replot 7)set xrange [0:5] 8)set yrange [-2:2] 9)replot

Line Types ● gnuplot uses the with keyword to specify the line type ● Line types supported by gnuplot: 1) lines 2) points 3) linespoints 4) impulses 5) dots 6) steps

Examples gnuplot> plot cos(x) with points gnuplot> plot sin(x) with impulses gnuplot> plot sin(x) with linespoints gnuplot> plot sin(x) with steps

Line Type Attribute ● Each line type has associated attributes, including color, style, and width; ● Additional examples: ● For more information and examples type “help with” at the gnuplot command prompt. gnuplot> plot sin(x) lt -1 with lines # adds black line gnuplot> replot cos(x) lt 0 with lines # adds white (dotted) line gnuplot> replot sin(x)*cos(x) lt 1 with lines # adds red line gnuplot> replot sin(x)/cos(x) lt 2 with lines # adds green line

Terminal Types in gnuplot ● gnuplot uses the current “terminal type” to determine in what way to output the current plot ● for example, in interactive mode gnuplot automatically sets the terminal type to be “x11” when started ● this is how we can see the plots even when they're created on a remote machine while in interactive mode

Saving Plots ● simply set the terminal type to the format you wish it save (e.g., postscript, jpeg, etc) ● the following example saves a plot to a postscript file: gnuplot> set terminal postscript Terminal type set to 'postscript' Options are 'landscape noenhanced monochrome blacktext \ dashed dashlength 1.0 linewidth 1.0 defaultplex \ palfuncparam 2000,0.003 \ butt "Helvetica" 14' gnuplot> set output "sinplot.ps" gnuplot> plot sin(x) gnuplot> ! ls -l sinplot.ps -rw-r--r-- 1 estrabd loniadmin Jun 2 15:19 sinplot.ps !

More Terminal Info ● reading the help on “terminal” provides a lot of good information about what types are supported ● to view the help, type in “help terminal” at the gnuplot prompt

Command Recap (please try) 1)plot cos(x) with points 2)plot sin(x) with impulses 3)plot sin(x) with points 4)plot sin(x) with linespoints 5)plot sin(x) with steps 6)plot sin(x) lt -1 with lines 7)replot cos(x) lt 0 with lines 8)replot sin(x)*cos(x) lt 1 with lines 9)set terminal postscript 10)set output “sin.ps” 11)replot 12)help terminal

Working With Data Sets # X Y1 Y2 Y gnuplot> plot "test.dat" using 1:2 with lines,\ "test.dat" using 1:3 with lines,\ "test.dat" using 1:4 with lines test.dat data from:

Calculations Using Column Data # X Y1 Y2 Y gnuplot> plot "test.dat" using 1:2 with points,\ "test.dat" using 1:($2*2) with points,\ "test.dat" using 1:(sqrt($2)) with points,\ "test.dat" using 1:(log($2)) with points test.dat data from:

Different Data Sets in a Single File # X Y Yerror gnuplot> plot "test.dat" using 1:2 with lines data from: test.dat 2 blank lines b/w data sets

Filtering Data ● gnuplot allows for shell commands to be embedded into plot commands ● this ability provides for a great amount of flexibility when plotting data gnuplot> plot "head -n 4 test.dat" using 1:2 with lines,\ "tail -n 3 test.dat" using 1:3 with lines,\ "cat test.dat |./filter.pl" using 1:4 with lines

3D Plotting ● plotting in 3D requires the “splot” command, which is analogous to the familiar “plot” command gnuplot> splot(x**2)*(y**2)

3D Plotting ● the following moves the z-axis up to the xy plane gnuplot> set ticslevel 0 gnuplot> splot(x**2)*(y**2)

Rotating View ● when a 3D plot is created, one may “drag” the image around to adjust the view ● (see live example)

Contours ● contours may be projected onto the z-axis gnuplot> set contour gnuplot> set cntrparam levels 10 gnuplot> set cntrparam levels incremental -1, 0.2, 1 gnuplot> set cntrparam levels discrete -0.2, -0.5, 0.2, 0.5 gnuplot> splot (x**2)*(y**2)

3D Data Sets # X Y Z data from gnuplot> splot "test3.dat" using 1:2:3 with lines test3.dat

Automating gnuplot ● gnuplot supports batch scripting, which allows the automating of tedious plotting commands #!/usr/bin/gnuplot -persist # set terminal set terminal x11 # plot a simple function plot sin(x) # # save as postscript file # set terminal postscript set output "test.ps" replot first line is like a shell script and denotes the application to use, including any options “-persist” tells gnuplot to keep the plot on the screen even after the script has finished executing set terminal to X11 plot function, will appear on screen save plot as a postscript file on the remote host a comment, ignored by gnuplot test.gp

Automating gnuplot ● save to “test.gp” ● To run: – make executable chmod 755 test.gp – run with,./test.gp ● Alternatively, gnuplot accepts STDIN: cat test.gp | gnuplot -persist or gnuplot -persist < test.gp

Putting It All Together #!/usr/bin/gnuplot -persist # set terminal set postscript # 2d data set output “2d-test.ps” plot "test.dat" using 1:2 with lines,\ "test.dat" using 1:3 with lines,\ "test.dat" using 1:4 with lines # 3d data set output “2d-test.ps” splot "test3.dat" using 1:2:3 with lines # filtered data set output “filtered-test.ps” plot "head -n 4 test.dat" using 1:2 with lines,\ "tail -n 3 test.dat" using 1:3 with lines,\ "cat test.dat |./filter.pl" using 1:4 with lines # advanced use shell escapes # --example requires ImageMagik's convert utility ! convert 2d-test.ps 2d-test.jpg # create jpg from ps ! convert 3d-test.ps 3d-test.jpg # create jpg from ps

References ●

Additional Resources ● ● ● ● ● Google (keywords, “gnuplot tutorial”, “gnuplot how to”, etc) ● gnuplot's build-in help (type “help” at the interactive prompt)