Wednesday, October 19, 2011

Broken axes graph in gnuplot (3)

To plot a x-axes broken graph with datafile, the two methods described in the last two posts are also suitable. The first method can be applied straightforwardly. And now we come to an example to apply the second method to a datafile plotting.

Consider such a case, an experiment team research on a material's thermodynamical properties. They heat it and record the temperature for 13 hours the first day, then its time for they to go home. And they go on their recording the second day. At last they get a data file like the following one.
0.00    25.76 
1.00   29.91 
2.00   35.33 
3.00   38.85 
4.00   43.15 
5.00   47.35 
6.00   50.45 
7.00   53.55 
8.00   56.12 
9.00   57.31 
10.00  59.11 
11.00  62.21 
12.00  62.17 
13.00  63.05 

23.00  63.56 
24.00  62.98 
25.00  66.05 
26.00  65.88 
27.00  64.70 
28.00  65.37 
29.00  63.12 
30.00  65.66 
31.00  66.14 
32.00  64.92 
33.00  65.68 
34.00  64.01 
35.00  63.50
36.00   63.75
We can find that their is a break when they go home. We will use a broken axes graph to deal with this break.
set term post eps enhanced
set output "broken_axes3.png"
set xrange [0:36-10+0.5]
set yrange [25:70]
set border 2+8
set arrow 1 from 0,25 to 13,25 nohead
set arrow 2 from 13.5,25 to 26.5,25 nohead
set arrow 3 from 0,70 to 13,70 nohead
set arrow 4 from 13.5,70 to 26.5,70 nohead

set arrow 5 from 12.75,24 to 13.25,26 nohead
set arrow 6 from 13.25,24 to 13.75,26 nohead
set arrow 7 from 12.75,69 to 13.25,71 nohead
set arrow 8 from 13.25,69 to 13.75,71 nohead

set xtics ("0" 0, "4" 4, "8" 8, "12" 12,\
           "24" 14.5, "28" 18.5, "32" 22.5, "36" 26.5)
set xlabel "Time:t(h)"
set ylabel "Temperature:T({/Symbol \260}C)"
plot "data.dat" u ($1<13. ?$1: $1>13. ?($1-9.5):1/0):2 w lp lw 2 ps 2 notitle
In this script the key point is "u ($1<13 ?$1: $1>13 ?($1-9.5):1/0):2" which transform range [23:36] to range [13.5:26.5] and let range [0:13] uneffected. The followng piture is broken_axes3.png (This png file is converted from broken_axes.eps).

Broken x-axes graph plotted using gnuplot

2 comments:

  1. Should be:
    set output "broken_axes3.eps"
    instead of png.

    ReplyDelete

Creative Commons License
Except as otherwise noted, the content of this page is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.