1
$\begingroup$

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

F vs x

but with different function.

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

$\endgroup$
6
  • $\begingroup$ F[] is a function of x and y, how can one create "a 2D plot of F[ ] vs x"? $\endgroup$
    – xzczd
    Sep 30 '20 at 6:01
  • $\begingroup$ 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 $\endgroup$
    – John Wick
    Sep 30 '20 at 6:03
  • $\begingroup$ 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? $\endgroup$
    – xzczd
    Sep 30 '20 at 6:09
  • $\begingroup$ Thanks I think your first suggestion about basic parametricplot is correct, but how to show the y as color gradient $\endgroup$
    – John Wick
    Sep 30 '20 at 6:20
  • $\begingroup$ 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] $\endgroup$
    – xzczd
    Sep 30 '20 at 6:26
0
$\begingroup$

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}}]]

enter image description here

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

$\endgroup$
9
  • $\begingroup$ Sorry i think i have forgotted to log scale one axis $\endgroup$
    – John Wick
    Sep 30 '20 at 6:52
  • $\begingroup$ Can you please tell me how to plot this for the case of x and y log axis $\endgroup$
    – John Wick
    Sep 30 '20 at 7:00
  • $\begingroup$ @JohnWick Then how will you handle the plot in y<=0 range? $\endgroup$
    – xzczd
    Sep 30 '20 at 7:09
  • $\begingroup$ 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 $\endgroup$
    – John Wick
    Sep 30 '20 at 7:15
  • $\begingroup$ @JohnWick Do you need to rescale y axis or both x and y axis? $\endgroup$
    – xzczd
    Sep 30 '20 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.