Then, here is our script that was responsible for the figure
reset xmin = 0; xmax = 10; zmin = -0.4; zmax = 0.75 set view 60, 30 unset key; unset colorbox set border 1+16+128+1024 unset ytics; set xtics out nomirror; set ticslevel 0 set yrange [0:-0.1] set zrange [zmin:zmax] set grid front; unset grid set xtics xmin,2,xmax-1 set ztics zmin,0.2,zmax f(x) = exp(-x/4.0)*sin(x) c(x) = exp(-(x-xmax/3.0)*(x-xmax/3.0)/1.0) set xlabel 'Time [a.u.]' set label 2 'Amplitude [a.u.]' at graph -0.35, 0.3 rotate by 90 set parametric set iso 3, 3 set urange [xmin:xmax] set vrange [zmin:zmax] set table 'perspective1.dat' splot u, 0, v unset table set urange [xmin+0.2:xmax-0.2] set table 'perspective2.dat' splot u, 0, f(u) unset table unset parametric set size 1.4, 1.4 set palette defined (0 "#7b6cff", 1 "#eeeeff") splot 'perspective1.dat' u 1:2:3:(c($1)) w pm3d, \ 'perspective2.dat' u ($1+0.05):2:($3-0.02) w l lw 6 lc rgb "#888888", \ '' w l lw 6 lt 1
The trick that we use here is to plot in 3D, and take off all those elements of the figure that we do not actually need. In the beginning, we define a couple of variables, in order to make our life a bit easier. Then we unset the colorbox and the key, and set only those borders that we want to see. If you are interested in how I came up with those numbers in the definition of the border, just issue the command
?border
in the gnuplot prompt. After this, we keep unsetting things, and define our ranges. The next noteworthy command is
set grid front; unset grid
At first, this seems silly, but the reason is real: in the figure we have a background, which would obscure our tic marks. The way out of this problem is to push the tic marks to the front, which is achieved by setting the grid to the front. Since we do not actually need the grid, we unset it, but the setting, its front position, is still there. The tic marks inherit the position of the grid, and thus, they will be in the forefront.
The function definitions are f(x), the function that we want to plot, and c(x), which will determine the colouring of our background. Modify them accordingly.
We set the zlabel by hand, because it might not be possible to turn it by 90 degrees otherwise. (Not all terminals would support it.) Then we plot the background, and the function, both to a file, so that it will be easier to colour them in the next step, where we plot the real thing. Note that in the plot of the background, we use four columns, while there are only 3 in the data file. The fourth one determines the colour as the position on the graph. The colour is given by the function c(x), and the palette, which we defined one line earlier. You should change these two things, if you are not satisfied with the background you get. Finally, we plot the function twice. Once in gray, a bit shifted to the right and down, and for the second time, in red. In this way, we add a shadow to our curve. If you want to improve the shadow, you should look at my post from the 30th August
I should also add that we discussed a vertical skew. In case you want to skew the figure horizontally, all you have got to do is to plot on the x-y plain instead of x-z.
No comments:
Post a Comment