Automated Graphs Making

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

An exercise in automated graphs making

Roman Putanowicz
Institute of Computer Methods
in Civil Engineering (L-5)
Cracow University of Technology
<R.Putanowicz@L5.pk.edu.pl>
October 19, 2009

What is this

This file is an exercise in automated graph making. When I talk to students about Linux, text
tools, LATEX, and generally about UNIX philosophy of working, in many cases I see that
they politely accept my arguments, though they would prefer something more substantial,
something they could try themselves. So to strengthen my arguments I came with his little
exercise:
From the data, which can be downloaded from http://www.L5.pk.edu.pl/~ putanowr/
casesData.zip, create a document which looks exactly like this one (except this
introductory section).
1.1

Setup

There are 50 files. Each data file consist of two columns with 50 X-Y values. From that
values a graph is created by simply joining the points with segments. For each graph the
minimum and maximum Y value is found, and at the corresponding data point a box is
plotted highlighting the value. The X and Y values in the box are formatted with the
format %5.2f. Additionally the graph function is integrated using the trapezoidal rule and
the integral value is displayed in the centre of the graph.
1.2

Solution

My result in preparing the graphs was 3.5 hours including refreshing my knowledge of gnuplot
and some LATEX tools. I have used gnuplot, AWK, bash, LATEX and octave. All scripts,
including the one used for preparing data files, can be downloaded from http://www.l5.
pk.edu.pl/casesScripts.tar.gz. Mind however, that the scripts are rather quick and
dirty solution and not the best example of programming style.
1.3

Disclaimer

This exercise and my results do not poof absolute value of any tool or specific
working strategy. There is nothing like that, as you can always come with an
example where a different set of tools and a different working strategy would
be more appropriate. And this is exactly the point I would like to make it is
worth to know alternatives, even if they seem much unusual comparing to what
we are used to.
1

max0.91.00, 0.90

case01

0.8
0.7
0.6
0.5
Calculated with trapezoidal rule:
Z 2.00
fcase01 (x)dx = 0.258701

0.4

1.00

0.3
0.2
0.1
0
-0.1

min 1.49,-0.10

-0.2
1

1.2

1.4

1.6

1.8

Figure 1: Figure produced from data in file case01.

2
case02
max 1.24, 1.85

1.8
1.6
1.4
1.2

Calculated with trapezoidal rule:


Z 2.00
fcase02 (x)dx = 0.852356

1.00

0.8
0.6
0.4
0.2
0

min 1.76,-0.15

-0.2
1

1.2

1.4

1.6

1.8

Figure 2: Figure produced from data in file case02.

1.2
case03
max 1.49, 1.06

1
0.8
0.6
0.4

Calculated with trapezoidal rule:


Z 2.00
fcase03 (x)dx = 0.148177

0.2

1.00

0
-0.2
-0.4
-0.6
-0.8
min 1.16,-0.94
-1
1

1.2

1.4

1.6

1.8

Figure 3: Figure produced from data in file case03.

1.4

max 1.12, 1.36

case04

1.2
1
0.8
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase04 (x)dx = 0.360030

0.4

1.00

0.2
0
-0.2
-0.4
-0.6

min 1.88,-0.64

-0.8
1

1.2

1.4

1.6

1.8

Figure 4: Figure produced from data in file case04.

1.8
case05
max 1.31, 1.62

1.6
1.4
1.2
1

Calculated with trapezoidal rule:


Z 2.00
fcase05 (x)dx = 0.498159

0.8

1.00

0.6
0.4
0.2
0
-0.2
min 1.10,-0.38

-0.4
1

1.2

1.4

1.6

1.8

Figure 5: Figure produced from data in file case05.

1.2
case06

max 1.08, 1.08


1
0.8
0.6
0.4
Calculated with trapezoidal rule:
Z 2.00
fcase06 (x)dx = 0.082978

0.2

1.00

0
-0.2
-0.4
-0.6
-0.8

min 1.92,-0.92
-1
1

1.2

1.4

1.6

1.8

Figure 6: Figure produced from data in file case06.

1.8

max 1.20, 1.75

case07

1.6
1.4
1.2
1
Calculated with trapezoidal rule:
Z 2.00
fcase07 (x)dx = 0.688681

0.8

1.00

0.6
0.4
0.2
0
-0.2min 1.06,-0.20
1

1.2

1.4

1.6

1.8

Figure 7: Figure produced from data in file case07.


1.2
case08

max 1.06, 1.08


1
0.8
0.6
0.4
Calculated with trapezoidal rule:
Z 2.00
fcase08 (x)dx = 0.077697

0.2

1.00

0
-0.2
-0.4
-0.6
-0.8

min 1.94,-0.92
-1
1

1.2

1.4

1.6

1.8

Figure 8: Figure produced from data in file case08.

1.8
case09

max 1.39, 1.72


1.6
1.4
1.2
1
Calculated with trapezoidal rule:
Z 2.00
fcase09 (x)dx = 0.652516

0.8

1.00

0.6
0.4
0.2
0
-0.2
min 1.06,-0.27
-0.4
1

1.2

1.4

1.6

1.8

Figure 9: Figure produced from data in file case09.

2
case10
max 1.45, 1.82

1.8
1.6
1.4
1.2

Calculated with trapezoidal rule:


Z 2.00
fcase10 (x)dx = 0.820301

1.00

0.8
0.6
0.4
0.2
0
-0.2
1

1.2

1.4

min 1.55,-0.18
1.6

1.8

Figure 10: Figure produced from data in file case10.

1.8
case11
max 1.14, 1.65

1.6
1.4
1.2
1

Calculated with trapezoidal rule:


Z 2.00
fcase11 (x)dx = 0.618569

0.8

1.00

0.6
0.4
0.2
0
-0.2

min 1.41,-0.33
-0.4
1

1.2

1.4

1.6

1.8

Figure 11: Figure produced from data in file case11.

2
max 1.04, 1.93

case12

1.8
1.6
1.4
1.2
Calculated with trapezoidal rule:
Z 2.00
fcase12 (x)dx = 0.931767

1.00

0.8
0.6
0.4
0.2
0

min 1.96,-0.07
-0.2
1

1.2

1.4

1.6

1.8

Figure 12: Figure produced from data in file case12.

1.6
case13

max 1.27, 1.54


1.4
1.2
1
0.8
Calculated with trapezoidal rule:
Z 2.00
fcase13 (x)dx = 0.502308

0.6

1.00

0.4
0.2
0
-0.2
-0.4

min 1.35,-0.45

-0.6
1

1.2

1.4

1.6

1.8

Figure 13: Figure produced from data in file case13.


1.2
case14
max 1.04, 1.07
1
0.8
0.6
0.4
Calculated with trapezoidal rule:
Z 2.00
fcase14 (x)dx = 0.095642

0.2

1.00

0
-0.2
-0.4
-0.6
-0.8
min 1.10,-0.88
-1
1

1.2

1.4

1.6

1.8

Figure 14: Figure produced from data in file case14.

1.6
case15

max 1.37, 1.50


1.4
1.2
1
0.8
Calculated with trapezoidal rule:
Z 2.00
fcase15 (x)dx = 0.457836

0.6

1.00

0.4
0.2
0
-0.2
-0.4
min 1.16,-0.49
-0.6
1

1.2

1.4

1.6

1.8

Figure 15: Figure produced from data in file case15.

1.6
case16

max 1.37, 1.50


1.4
1.2
1
0.8
Calculated with trapezoidal rule:
Z 2.00
fcase16 (x)dx = 0.457836

0.6

1.00

0.4
0.2
0
-0.2
-0.4
min 1.16,-0.49
-0.6
1

1.2

1.4

1.6

1.8

Figure 16: Figure produced from data in file case16.

max 1.33, 0.98

case17

0.9
0.8
0.7
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase17 (x)dx = 0.483081

0.5

1.00

0.4
0.3
0.2
0.1
0
1

1.2

min 1.41, 0.01


1.4

1.6

1.8

Figure 17: Figure produced from data in file case17.

max 1.67, 1.00


case18

0.9
0.8
0.7
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase18 (x)dx = 0.527791

0.5

1.00

0.4
0.3
0.2
0.1
min 1.51, 0.00

0
1

1.2

1.4

1.6

1.8

Figure 18: Figure produced from data in file case18.

10

max 1.35, 0.99

case19

0.9
0.8
0.7
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase19 (x)dx = 0.564146

0.5

1.00

0.4
0.3
0.2
0.1
min 1.69, 0.03

0
1

1.2

1.4

1.6

1.8

Figure 19: Figure produced from data in file case19.


1

max 1.43, 1.00

case20

0.9
0.8
0.7
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase20 (x)dx = 0.502645

0.5

1.00

0.4
0.3
0.2
0.1
min 1.33, 0.02

0
1

1.2

1.4

1.6

1.8

Figure 20: Figure produced from data in file case20.

11

1 1.04, 0.99
max

case21

0.9
0.8
0.7
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase21 (x)dx = 0.538807

0.5

1.00

0.4
0.3
0.2
0.1
min 1.51, 0.01

0
1

1.2

1.4

1.6

1.8

Figure 21: Figure produced from data in file case21.

max 1.80, 0.99


case22

0.9
0.8
0.7
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase22 (x)dx = 0.429588

0.5

1.00

0.4
0.3
0.2
0.1
0
1

1.2

1.4

1.6

min 1.82, 0.00


1.8

Figure 22: Figure produced from data in file case22.

12

max 1.86, 1.00


case23

0.9
0.8
0.7
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase23 (x)dx = 0.486651

0.5

1.00

0.4
0.3
0.2
0.1
min 1.92, 0.02

0
1

1.2

1.4

1.6

1.8

Figure 23: Figure produced from data in file case23.

max 11.00, 1.00

case24

0.9
0.8
0.7
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase24 (x)dx = 0.502124

0.5

1.00

0.4
0.3
0.2
0.1
0 min 1.08, 0.00
1

1.2

1.4

1.6

1.8

Figure 24: Figure produced from data in file case24.

13

1
max 1.80, case25
0.96
0.9
0.8
0.7
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase25 (x)dx = 0.497093

0.5

1.00

0.4
0.3
0.2
0.1
min 1.90, 0.02

0
1

1.2

1.4

1.6

1.8

Figure 25: Figure produced from data in file case25.


1

max 1.80, case26


0.98

0.9
0.8
0.7
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase26 (x)dx = 0.479911

0.5

1.00

0.4
0.3
0.2
0.1
0
1

1.2

1.4

min 1.53, 0.01


1.6

1.8

Figure 26: Figure produced from data in file case26.

14

1
max case27
1.86, 0.96
0.9
0.8
0.7
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase27 (x)dx = 0.576762

0.5

1.00

0.4
0.3
0.2
0.1
0 min 1.08, 0.00
1

1.2

1.4

1.6

1.8

Figure 27: Figure produced from data in file case27.

max 1.61, 0.98

case28

0.9
0.8
0.7
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase28 (x)dx = 0.494602

0.5

1.00

0.4
0.3
0.2
0.1
min 1.51, 0.02

0
1

1.2

1.4

1.6

1.8

Figure 28: Figure produced from data in file case28.

15

max 1.41, 0.99

case29

0.9
0.8
0.7
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase29 (x)dx = 0.486387

0.5

1.00

0.4
0.3
0.2
0.1
0
1

1.2

1.4

min 1.59, 0.01


1.6

1.8

Figure 29: Figure produced from data in file case29.

1
case30
max 1.86, 0.95
0.9
0.8
0.7
0.6
Calculated with trapezoidal rule:
Z 2.00
fcase30 (x)dx = 0.495551

0.5

1.00

0.4
0.3
0.2
0.1
min 1.78, 0.03
0
1

1.2

1.4

1.6

1.8

Figure 30: Figure produced from data in file case30.

16

0.4
max 1.00, 0.39

case31

0.35

0.3

Calculated with trapezoidal rule:


Z 2.00
fcase31 (x)dx = 0.248752

0.25

1.00

0.2

0.15

min 1.96, 0.15

0.1
1

1.2

1.4

1.6

1.8

Figure 31: Figure produced from data in file case31.


0.4
max 1.02, 0.39

case32

0.35

0.3
Calculated with trapezoidal rule:
Z 2.00
fcase32 (x)dx = 0.248737
1.00

0.25

0.2

min 1.90, 0.16


0.15
1

1.2

1.4

1.6

1.8

Figure 32: Figure produced from data in file case32.

17

0.4
max 1.02, 0.39

case33

0.35

0.3

Calculated with trapezoidal rule:


Z 2.00
fcase33 (x)dx = 0.247911

0.25

1.00

0.2

0.15
min 2.00, 0.14

0.1
1

1.2

1.4

1.6

1.8

Figure 33: Figure produced from data in file case33.

0.4
case34
max 1.02, 0.38

0.35

0.3
Calculated with trapezoidal rule:
Z 2.00
fcase34 (x)dx = 0.251082
1.00

0.25

0.2

min 1.98, 0.15

0.15
1

1.2

1.4

1.6

1.8

Figure 34: Figure produced from data in file case34.

18

0.45
case35

max0.41.00, 0.40

0.35

0.3

Calculated with trapezoidal rule:


Z 2.00
fcase35 (x)dx = 0.250477
1.00

0.25

0.2

0.15

min 1.98, 0.15

0.1
1

1.2

1.4

1.6

1.8

Figure 35: Figure produced from data in file case35.

0.45
case36

max0.41.00, 0.40

0.35

0.3

Calculated with trapezoidal rule:


Z 2.00
fcase36 (x)dx = 0.249108
1.00

0.25

0.2

0.15

min 2.00, 0.15

0.1
1

1.2

1.4

1.6

1.8

Figure 36: Figure produced from data in file case36.

19

0.4
case37

max 1.02, 0.39

0.35

0.3

Calculated with trapezoidal rule:


Z 2.00
fcase37 (x)dx = 0.252423

0.25

1.00

0.2

0.15
min 2.00, 0.14

0.1
1

1.2

1.4

1.6

1.8

Figure 37: Figure produced from data in file case37.


0.4
max 1.00, 0.39

case38

0.35

0.3
Calculated with trapezoidal rule:
Z 2.00
fcase38 (x)dx = 0.253085
1.00

0.25

0.2

min 1.96, 0.15

0.15
1

1.2

1.4

1.6

1.8

Figure 38: Figure produced from data in file case38.

20

0.45
case39

max0.41.00, 0.40

0.35

0.3

Calculated with trapezoidal rule:


Z 2.00
fcase39 (x)dx = 0.251324
1.00

0.25

0.2

0.15

min 1.96, 0.15

0.1
1

1.2

1.4

1.6

1.8

Figure 39: Figure produced from data in file case39.

0.4
case40

max 1.00, 0.38

0.35

0.3

Calculated with trapezoidal rule:


Z 2.00
fcase40 (x)dx = 0.254562

0.25

1.00

0.2

0.15
min 1.98, 0.14

0.1
1

1.2

1.4

1.6

1.8

Figure 40: Figure produced from data in file case40.

21

0.4
max 1.04, 0.39

case41

0.35

0.3

Calculated with trapezoidal rule:


Z 2.00
fcase41 (x)dx = 0.250343

0.25

1.00

0.2

0.15

min 2.00, 0.14

0.1
1

1.2

1.4

1.6

1.8

Figure 41: Figure produced from data in file case41.

0.4
max 1.02, 0.39

case42

0.35

0.3
Calculated with trapezoidal rule:
Z 2.00
fcase42 (x)dx = 0.254795
1.00

0.25

0.2

min 1.96, 0.16


0.15
1

1.2

1.4

1.6

1.8

Figure 42: Figure produced from data in file case42.

22

0.45
case43

max0.41.00, 0.40

0.35

0.3

Calculated with trapezoidal rule:


Z 2.00
fcase43 (x)dx = 0.254965
1.00

0.25

0.2

0.15
min 1.98, 0.14

0.1
1

1.2

1.4

1.6

1.8

Figure 43: Figure produced from data in file case43.


0.45
case44

max 1.00, 0.41


0.4

0.35

Calculated with trapezoidal rule:


Z 2.00
fcase44 (x)dx = 0.251890

0.3

1.00

0.25

0.2

0.15
1

1.2

1.4

1.6

1.8

min 1.94, 0.15


2

Figure 44: Figure produced from data in file case44.

23

0.4
max 1.04, 0.40

case45

0.35

0.3

Calculated with trapezoidal rule:


Z 2.00
fcase45 (x)dx = 0.256684

0.25

1.00

0.2

0.15
min 2.00, 0.14

0.1
1

1.2

1.4

1.6

1.8

Figure 45: Figure produced from data in file case45.

max0.41.00, 0.40

case46

0.35

0.3

Calculated with trapezoidal rule:


Z 2.00
fcase46 (x)dx = 0.254963

0.25

1.00

0.2

0.15

min 2.00, 0.15

0.1
1

1.2

1.4

1.6

1.8

Figure 46: Figure produced from data in file case46.

24

0.4
case47
max 1.08, 0.38
0.35

0.3

Calculated with trapezoidal rule:


Z 2.00
fcase47 (x)dx = 0.258991

0.25

1.00

0.2

0.15

min 1.94, 0.14

0.1
1

1.2

1.4

1.6

1.8

Figure 47: Figure produced from data in file case47.

0.4
case48
max 1.02, 0.38

0.35

0.3
Calculated with trapezoidal rule:
Z 2.00
fcase48 (x)dx = 0.257156
1.00

0.25

0.2

0.15
1

1.2

1.4

1.6

1.8

min 1.98, 0.15


2

Figure 48: Figure produced from data in file case48.

25

0.45
case49

max
0.4 1.02, 0.40

0.35

0.3

Calculated with trapezoidal rule:


Z 2.00
fcase49 (x)dx = 0.252673
1.00

0.25

0.2

0.15
min 1.98, 0.14

0.1
1

1.2

1.4

1.6

1.8

Figure 49: Figure produced from data in file case49.


0.4
case50

max 1.08, 0.39

0.35

0.3
Calculated with trapezoidal rule:
Z 2.00
fcase50 (x)dx = 0.259834
1.00

0.25

0.2

min 2.00, 0.16

0.15
1

1.2

1.4

1.6

1.8

Figure 50: Figure produced from data in file case50.

26

You might also like