This is another post when I'm going to try to explain how to use the multiplot environment. In this case, I'm going to use the multiplot environment, but setting the position of the plots "by hand" in order to get the effect of one plot inside other. This may be useful if you want to show some detail of a small part of the general plot. This is the final result:
Well, the overall idea is the same than in this other post, but in this case I won't use the automatic layout. In order to set the size and position of the plot manually, you have to use the parameters size and origin, respectively. You have to know that the units of these commands are the size of the whole figure, and first number refers to x axis. Then for example, set size 1,1 means use the whole figure as the size of the plot. Analogously, set origin 0.5,0.5 sets the bottom left corner of the plot in the centre of the figure.Other example: if you want to insert two plots, one over the other, you could set size 1,0.5 in order to reduce the vertical size to half the total, and then use set origin 0,0.5 before plotting the second graph.
This is the code to generate the figure above. I have plotted also a rectangle and an arrow. You can skip that, it's not really important, but I just wanted to show some more capabilities of Gnuplot.
gnuplot << TOENDset terminal postscript eps color enhancedset output 'multiplot2.eps'#set ytics 0.25#set format y "%.2f"set multiplot
# Bigger plot optionsset yrange [-4:5]set size 1,1set origin 0,0set title 'Whole plot'set xlabel 'time/s'set ylabel 'variable/m'
### This is to plot the square. You can skip this ###set arrow from 1.1,-0.9 to 1.0,0.3 lw 1 back filledset arrow from 0.9,-3 to 1.5,-3 lw 1 front noheadset arrow from 0.9,-1 to 1.5,-1 lw 1 front noheadset arrow from 0.9,-1 to 0.9,-3 lw 1 front noheadset arrow from 1.5,-1 to 1.5,-3 lw 1 front nohead###################################
# This plots the big plotplot 'datos.dat' w l lt 1 lc 3 lw 3 t ''
# Now we set the options for the smaller plotset size 0.6,0.4set origin 0.2,0.5set title 'Zoom'set xrange [0.9:1.5]set yrange [-3:-1]set xlabel ""set ylabel ""unset arrowset grid
# And finally let's plot the same set of data, but in the smaller plotplot 'datos.dat' w l lt 1 lc 3 lw 3 t ''# It's important to close the multiplot environment!!!
unset multiplotTOEND
0 Comments:
Post a Comment