3
$\begingroup$

I would like to draw a circular segment with a colour gradient based on the radial distance from the center. Currently I have:

ParametricPlot[
    {ρ Cos[θ], ρ Sin[θ]}, {ρ, 5, 25}, {θ, π/4, (3 π)/4},
    ColorFunction -> Function[{x, y}, Hue[Sqrt[x^2 + y^2]]],
    Axes -> False, Frame -> False
]

which gives the following:

enter image description here

Which clearly is not coloured according to the radial distance from the centre. How can I do this?

$\endgroup$

1 Answer 1

4
$\begingroup$

The problem you're encountering is due to ColorFunctionScaling->True. Set it to False, and then normalize your Hue function:

ParametricPlot[
    {ρ Cos[θ], ρ Sin[θ]},
    {ρ, 5, 25},
    {θ, π/4, 3 π/4},
    ColorFunction->Function[{x,y},Hue[Sqrt[x^2+y^2]/25]],
    ColorFunctionScaling->False,
    Axes->False,
    Frame->False
]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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