This is another post about Gnuplot, and how to use multiplot and zoom-in on data points/ lines that can be difficult to distinguish. Using multiplot will allow to place a secondary plot inside the main one, “emulating” a zoom on data points, by using a different scale. The plot will be placed to specific coordinates for clarity.
Lets create a simple plot to start with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
set title "Zoom Example" set xlabel "" set ylabel "" #set the scale for the example set yrange[1:1000000.000000] set ytics (1.000000,10.000000,100,1000,10000,100000,1000000) nomirror set logscale y set terminal pngcairo enhanced font 'Helvetica,10' set output 'example.png' #create the main plot set style data linespoints plot "example.dat" using 1:2 title columnheader lt -1,\ "example1.dat" using 1:2 title columnheader lt -1 |
With this simple data set example :
1 2 3 4 5 |
ID Data1 1 2 2 2 3 2 4 2 |
1 2 3 4 5 |
ID Data2 1 1.9 2 1.9 3 1.9 4 1.9 |
Sometimes, it is not possible to plot data with a different scale, and it is impossible to distinguish different data points. It is possible to use a simple “magnifier” trick, by using the following script instead.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
set title "Zoom Example" set xlabel "" set ylabel "" #set the scale for the example set yrange[1:1000000.000000] set ytics (1.000000,10.000000,100,1000,10000,100000,1000000) nomirror set logscale y set terminal pngcairo enhanced font 'Helvetica,10' set output 'example.png' #set the arrow set arrow from 2,2.1 to 1.6,15 lw 1 back filled #set multiplot set multiplot #create the main plot set style data linespoints plot "example.dat" using 1:2 title columnheader lt -1,\ "example1.dat" using 1:2 title columnheader lt -1 #set the specs for the second plot set size 0.6,0.4 set origin 0.2,0.2 set title 'Zoom' set xrange [2:3] set yrange [2.1:1.8] set ytics(2.1,1.8) nomirror set xlabel "" set ylabel "" unset arrow set grid #create the second plot set style data linespoints plot "example.dat" using 1:2 notitle lt -1,\ "example1.dat" using 1:2 notitle lt -1 #end the multiplot unset multiplot |
Using this trick, a second plot is created, with a different scale and it looks like a simple magnifier allowing the reader to have a clear idea on how the points are laid out or simply place emphasis on certain data points.
Post a Comment