We know that at a special viewpoint a surface can appear like a line. We also know that gunplot can plot colored surface with pm3d plotting style. So we may expand our line to a surface. Plot the surface with pm3d. View it in a special viewpoint. Now we come to realize our idea.
Note that the view should be set to a value near "90,0" but not exactly "90,0" (if view exactly equals "90,0", "linwidth" of the curve is 0), here we choose "89.5,0". Compared to the previous one, this method takes less time. The output picture file is shown below.
reset set term png set output "gradient_colored_curve2.png" set isosample 200,2 #As along y-axis the surface has a constant value, #the samples along y-axis can set to be a small value. set palette rgbformulae 7,5,15 unset colorbox set xyplane relative 0 set xtics offset 0,-1 #putting xtics label 1 character lower makes the plotting nicer unset ytics #ytics is not necessary unset border #the border will plot manually #plot axes manually set arrow 1 from graph 0,0,0 to graph 1.1,0,0 set arrow 2 from graph 0,0,0 to graph 0,0,1.1 #plot xtics manually set for [i=-10:10:5] arrow from i,0,-1.0 to i,0,-0.95 nohead set view 89.5,0 #map the 3-d surface to coordinate plane splot sin(x) w pm3d notitle
|Gradient colored curve plotted by gnuplot|