1
$\begingroup$

I have a function $Q(y)$, which I would like to plot this radially using varying color shades to show the variation in the function. I'm looking for a 2D surface plot, maybe like DensityPlot, but circular and versus one parameter ($y$). An example use case would be plotting the angular velocity of a galaxy with color, assuming that it is radially symmetric.

You can assume an arbitrary $Q(y)$, e.g. $1/y^2$. Now for each $y$, we have a value for $Q(y)$. One way to show the results is to plot $Q(y)$ vs. $y$. But I would prefer if I can have a circular plot where for each $y$ there is a ring where $y$ is constant. I would like the color of this ring to be determined by the value of $Q(y)$.

$\endgroup$
  • 1
    $\begingroup$ Maybe you are looking for PolarPlot? $\endgroup$ – Henrik Schumacher May 5 '18 at 12:32
  • 1
    $\begingroup$ If PolarPlot isn't what you're looking for, do you have an example of what kind of plot you're trying to make? $\endgroup$ – eyorble May 5 '18 at 13:04
  • 2
    $\begingroup$ So what about DensityPlot[Q[Sqrt[x^2+y^2]], {x, -5, 5}, {y, -5, 5}], assuming that $0 \le r \le 5$ is an appropriate range for your plot? $\endgroup$ – eyorble May 5 '18 at 17:41
  • 1
    $\begingroup$ Maybe you are looking for somthing like this: f = r \[Function] 1/2 (1 + Sin[5 Pi r]); ParametricPlot[ r {Cos[t], Sin[t]}, {r, 0, 1}, {t, -Pi, Pi}, ColorFunction -> {{x, y, r, t} \[Function] ColorData["SunsetColors"][f[r]]}, Background -> Black ] $\endgroup$ – Henrik Schumacher May 5 '18 at 18:50
  • 1
    $\begingroup$ @HenrikSchumacher Since you got it right, it would be good if you would post it as an answer so that the question does not formally stay unanswered. I'll give you a +1 if you do it :) $\endgroup$ – C. E. May 6 '18 at 9:05
4
$\begingroup$

It appears to me from the comments that you a looking for this:

f = r \[Function] 1/2 (1 + Sin[5 Pi r]); 
ParametricPlot[ r {Cos[t], Sin[t]}, {r, 0, 1}, {t, -Pi, Pi},
 ColorFunction -> {{x, y, r, t} \[Function] ColorData["SunsetColors"][f[r]]}, 
 Background -> Black 
]

enter image description here

$\endgroup$
1
$\begingroup$

DensityPlot can also be used for this by substituting the appropriate expression for radius into the function's argument. For example, assuming that $0 \le r \le 5$ is an appropriate range to plot your function over, you can input:

DensityPlot[Q[Sqrt[x^2+y^2]], {x, -5, 5}, {y, -5, 5}]

You can borrow the ColorFunction and Background from Henrik Schumacher's answer if you prefer, as well.

$\endgroup$

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.