Sunday, September 4, 2011

Shadow to the key in Gnuplot

Yesterday we talk about shadow to a curve in gnuplot . But the key is not plotted. Now we come to add a shadowed key to our graph. The method is the same as before, plotting the objects two or more times. The following is an example gnuplot script.
set term png
set output "shadowkey.png"
set object 1 rectangle from graph 0.91,0.89 \
    to graph 0.66,0.74 fillstyle solid 1.0 noborder \
    fc rgb"#cccccc"	#key-box shadow
set object 2 rectangle from graph 0.9,0.9 \
    to graph 0.65,0.75 fc rgb"#ffffff"    #key-box
set arrow 1 lw 7 lc rgb"#cccccc" from graph 0.78,0.82 \
    to graph 0.86,0.82 nohead #samle-line shadow
set arrow 2 lw 7 lc rgb"red" from graph 0.77,0.83 \
    to graph 0.85,0.83 nohead     #sample-line
set label 1 "f(x)" at graph 0.7,0.83	#key label
set xrange [-15:15]
plot f(x-dx)-dy w l lw 7 lc rgb"#cccccc" notitle,\
     f(x) w l lw 7 lc rgb"red" notitle
Because gnuplot can not give us enough control on the key by using command "set key ...", in this script we draw the key manually using rectangles,arrows and label. The final appearance of shadow1.png is shown below.

Shadow to the key in gnuplot

No comments:

Post a Comment

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.