This is an old revision of the document!


Lab 05 - Plotting

Objectives

  • Offer an introduction to Gnuplot
  • Get you familiarised with basic plots in Gnuplot

Contents

Gnuplot Introduction

Gnuplot is a free, command-driven, interactive, function and data plotting program. It can be downloaded at https://sourceforge.net/projects/gnuplot/. The official Gnuplot documentation can be found at http://gnuplot.sourceforge.net/documentation.html.

It was originally created to allow scientists and students to visualize mathematical functions and data interactively, but has grown to support many non-interactive uses such as web scripting. It is also used as a plotting engine by third-party applications such as Octave.

The command language of Gnuplot is case sensitive, i.e. commands and function names written in lowercase are not the same as those written in capitals. All command names may be abbreviated as long as the abbreviation is not ambiguous. Any number of commands may appear on a line, separated by semicolons (;). Strings may be set off by either single or double quotes, although there are some subtle differences. See syntax (p. 44) and quotes (p. 44) for more details in the Gnuplot documentation (http://gnuplot.sourceforge.net/docs_5.0/gnuplot.pdf).

Commands may extend over several input lines by ending each line but the last with a backslash (\). The backslash must be the last character on each line. The effect is as if the backslash and newline were not there. That is, no white space is implied, nor is a comment terminated.

For built-in help on any topic, type help followed by the name of the topic or help ? to get a menu of available topics.

Tutorial

01. [10p] Basic Plotting

02. [10p] Fitting

03. [10p] Gnuplot Scripts

04. [10p] Animations

Tasks

05. [20p] Gnuplot graphs

Using the Gnuplot documentation, implement a script that plots four graphs. Use the data from data4.txt as follows: the first graph should plot columns 1 and 2, the second columns 1 and 3, the third one columns 1 and 4, and the fourth one should be a 3D graph plotting columns 1, 2 and 3.

  • Use different colours for the data in each graph.
  • Remove the keys for each graph.
  • Give a title to each graph.
  • Give names to each of the axes: X or Y (or Z for the 3D graph). In the case of the 3D graph: Make the numbers on the axes readable, and correct the position of the names of the axes if these are displayed over the axes numbers.
  • Make the script generate the .eps file containing your plot.

Hint: Consider the following commands: set key, xlabel, set title, set xtics, set terminal, set output, using.

06. [30p] Gnuplot bar graphs

Use Gnuplot and the data from autoData.txt to generate separate bar graphs for the following:

  • The ”MidPrice” of all the ”small” cars.
  • The average fuel consumption (MPG - miles per gallon) for all the ”large” cars.
  • The ”MaxPrice” over the average fuel consumption for all ”chevrolet” and ”ford” cars.

The graphs should be as complete as possible (title, axes names, etc.)

Hint: Gnuplot conditional plotting.

07. [10p] Feedback

Please take a minute to fill in the feedback form for this lab.

ep/labs/05.1572188802.txt.gz · Last modified: 2019/10/27 17:06 by emilian.radoi
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0