An alternative way to realize a linear gradient colored background is using the image plotting style. Let us first look at our final script and then explain it.
reset
set table "back.dat" #creat a data file
set isosample 2,200 #containing linear
splot y #gradient color
unset table #information
splot y #Get the max value of z
max=GPVAL_Z_MAX
set term png
set output "backgradient2.png"
set multiplot
#plot the background
set lmargin at screen 0
set rmargin at screen 1
set bmargin at screen 0
set tmargin at screen 1
unset border
unset tics
set palette defined(0"white",max"#ccffcc") #set gradient color
plot "back.dat" w ima
#plot the curve of sin(x)
set border 1+2+4+8
set tics
set lmargin
set rmargin
set bmargin
set tmargin
plot sin(x) w l lw 2 lc rgb"black" notitle
unset multiplot
!del back.dat
#in unix system the above command may should be change to "!rm back.dat"
In this script, firstly we produce a date file "back.dat" which contain linear gradient color information. Then in a multiplot environment we plot the background using command '''plot "back.dat" w ima''' and figure of sin(x) using '''plot sin(x) w l lw 2 lc rgb"black" notitle'''. Before plotting the background we set l,r,b,tmargin to be 0,1,0,1 respectively, thus the background is filled the whole picture, and border and tics are unset. After that all of border,margins and tics are set again. "! del back.dat" is used to delete temporary data file back.dat. backgradient2.png is show below:
 |
| Linear gradient colored background |
No comments:
Post a Comment