# Create a color gradient using a variable?

Let say I have a function

F[x_,y_]:=x^2+6y^(3/2)


Now I want to plot a 2D plot of F[ ] vs x and y, and need to use y variable as a color gradient. Here I want to vary y as a color axis and the values of F will be plotted against x it will be like this

but with different function.

The question was asked several day ago in Wolfram Community but I not got any fruitful answer.

• F[] is a function of x and y, how can one create "a 2D plot of F[ ] vs x"? Sep 30 '20 at 6:01
• One can also vary y but in the color axis i.e. thiss plot is the 2D projection of the F(x,y) vs x vs y 3D plot Sep 30 '20 at 6:03
• If it's a 2D projection, shouldn't it be a region like ParametricPlot[{x, x^2 + 6 y^(3/2)}, {x, -4, 4}, {y, -1, 1}]? Or you just want to plot at a certain y==a and use the deriative at y==a for coloring? Sep 30 '20 at 6:09
• Thanks I think your first suggestion about basic parametricplot is correct, but how to show the y as color gradient Sep 30 '20 at 6:20
• Something like this?: ParametricPlot[{x, x^2 + 6 y^(3/2)}, {x, -4, 4}, {y, -1, 1}, ColorFunction -> Function[{xaxis, yaxis, x, y}, ColorData["Rainbow"][y]], AspectRatio -> 1/GoldenRatio] Sep 30 '20 at 6:26

Try this:

{yL, yR} = {-1, 1}; colorfunc = "Rainbow";
ParametricPlot[{x, x^2 + 6 y^(3/2)}, {x, -4, 4}, {y, yL, yR},
ColorFunction -> Function[{xaxis, yaxis, x, y}, ColorData[colorfunc][y]],
AspectRatio -> 1/GoldenRatio, PlotLegends -> BarLegend[{colorfunc, {yL, yR}}]]


Do notice this visualization won't work well on those functions oscillating in y direction.

• Sorry i think i have forgotted to log scale one axis Sep 30 '20 at 6:52
• Can you please tell me how to plot this for the case of x and y log axis Sep 30 '20 at 7:00
• @JohnWick Then how will you handle the plot in y<=0 range? Sep 30 '20 at 7:09
• In my case y<=0 is not needed, and also I am facing a issue in merging a list plot with same plotrange with this parametric plot Sep 30 '20 at 7:15
• @JohnWick Do you need to rescale y axis or both x and y axis? Sep 30 '20 at 8:15