Run with lualatex
\documentclass{standalone}
\usepackage{pst-hsb}
\begin{document}
\begin{pspicture}(-0.75,-0.75)(11,5)
% \psgrid(0,-4)(10,4)
\psaxes{->}(0,0)(11,5)
\pslineHSBlinewidth=1mm,HueBegin=0,HueEnd=0.5(10,1)
\pslineHSBlinewidth=1mm,HueBegin=0.5,HueEnd=0.7(10,3)
\pslineHSBlinewidth=1mm,HueBegin=0.8,HueEnd=1(10,5)
\end{pspicture}
\end{document}

Or only for two given colors. Maybe that it will be part of an update of PSTricks ...
\documentclass{article}
\usepackage{pstricks-add}
\makeatletter
\define@key[psset]{pstricks}{startColor}[black]{%
\colorlet{tempcolor}[rgb]{#1}% we need rgb
\pst@getcolor{tempcolor}\ps@startColor}
\define@key[psset]{pstricks}{endColor}[white]{%
\colorlet{tempcolor}[rgb]{#1}%
\pst@getcolor{tempcolor}\ps@endColor}
\psset[pstricks]{startColor=black,endColor=white}
\def\pscolorLine{\def\pst@par{}\pst@object{pscolorLine}}
\def\pscolorLine@i{%
\pst@getarrows{%
\begin@OpenObj
\pscolorLine@ii}}
\def\pscolorLine@ii(#1){@ifnextchar({\pscolorLine@iii(#1)}{\pscolorLine@iii(0,0)(#1)}}%
\def\pscolorLine@iii(#1,#2)(#3,#4){%
\use@par
\ifx\psk@arrowA@empty\else\psline[linecolor=\ps@startColor]{->}(!#3 0.5 mul #4 0.5 mul)(#1,#2)\fi
\ifx\psk@arrowB@empty\else\psline[linecolor=\ps@endColor]{->}(!#1 0.5 mul #2 0.5 mul)(#3,#4)\fi
\pst@getcoor{#1,#2}\pst@tempA
\pst@getcoor{#3,#4}\pst@tempB
\addto@pscode{
10 dict begin
[ \psgetRGBColorValues{\ps@startColor} ] dup == aload length 1 eq { dup dup } if
3 copy 3 array astore /startColor ED
[ \psgetRGBColorValues{\ps@endColor} ] dup == aload length 1 eq { dup dup } if
3 copy 3 array astore /endColor ED
% on stack R1 G1 B1 R2 G2 B2
4 -1 roll % R1 G1 R2 G2 B2 B1
sub 256 div /dB ED % R1 G1 R2 G2
3 -1 roll % R1 R2 G2 G1
sub 256 div /dG ED % R1 R2
exch sub 256 div /dR ED
\pst@tempB /Y2 ED /X2 ED
\pst@tempA /Y1 ED /X1 ED
Y2 Y1 sub X2 X1 sub atan /Angle ED
Y2 Y1 sub Angle sin dup 0 eq { pop }{ div } ifelse /L_line ED % line length
\ifx\psk@arrowA@empty\else
X2 X1 sub L_line div \psk@arrowlength\space mul \pst@number\psxunit mul X1 add /X1 ED
Y2 Y1 sub L_line div \psk@arrowlength\space mul \pst@number\psyunit mul Y1 add /Y1 ED
\fi
\ifx\psk@arrowB@empty\else
X2 X1 sub L_line div \psk@arrowlength\space mul \pst@number\psxunit mul X2 exch sub /X2 ED
Y2 Y1 sub L_line div \psk@arrowlength\space mul \pst@number\psyunit mul Y2 exch sub /Y2 ED
\fi
Y2 Y1 sub 256 div /dY ED
X2 X1 sub 256 div /dX ED
% dR dG dB == == ==
%startColor == endColor ==
\ifPst@noCurrentPoint\else\pst@cp\fi % current point?
0 1 255 {
/dIndex ED
%startColor ==
X1 Y1 moveto
X1 dX add Y1 dY add % start for coordinate array
gsave
lineto
CP /Y1 ED /X1 ED
\pst@number\pslinewidth SLW
startColor aload pop 3 copy setrgbcolor
% on stack r g b
dB add 3 1 roll % b+dB r g
dG add 3 1 roll % b+dB g+dG r
dR add 3 1 roll % b+dB g+dG r+dR
3 array astore /startColor ED
stroke
grestore
} for
end
}%
\end@OpenObj
\ignorespaces
}
\makeatother
\begin{document}
\begin{pspicture}linewidth=12pt,showgrid(5,5)
\pscolorLine(0,-5)(0,5)
\pscolorLinestartColor=cyan,endColor=magenta(5,0)
\pscolorLine[startColor=blue,endColor=green]{->}(-5,5)(5,-5)
\pscolorLine[startColor=red,endColor=blue]{<->}(-5,-5)(5,5)
\end{pspicture}
\end{document}

\parametricplotHSBcode is at http://pstricks.blogspot.com/2011/09/vos-courbes-aux-couleurs-de-larc-en.html. It appears not to be included in any package. – Martin J. Osborne Dec 14 '21 at 20:40\pslineHSBmacro has been written at some point (see https://tex.stackexchange.com/questions/406413/varying-the-color-along-pstricks-lines-circles-etc/ for a demo that contains not only a plot but also two lines with a gradient) but I could not find the code for this macro anywhere. I did find a subsection about\pslineHSBin the docs ofpst-hsbat https://archiv.dante.de/~herbert/texnik/source/pst-hsb/ but the code itself does not seem to be there. – Marijn Dec 14 '21 at 22:13\pslineHSBuses\parametricplotHSBalong the lines of\def\pslineHSB(#1,#2)(#3,#4){\parametricplotHSB{#1}{#3}{t t #1 sub #4 #2 sub #3 #1 sub div mul #2 add}}. That needs to be developed to handle vertical lines and allow for an optional argument, but those modifications seem easy. I guess one could do the same thing for\pscurve, although it seems that that would be much more difficult. – Martin J. Osborne Dec 15 '21 at 00:22