0
$\begingroup$

I have the following DensityPlot:

DensityPlot[Sin[x] Sin[y], {x, -Pi/4, Pi/4}, {y, -Pi/4, Pi/4}, ColorFunction -> "SunsetColors", PlotLegends -> Automatic]

enter image description here

Now I want to see only the values of density along the function "y = 1/2 (ArcCos[1 - Cos[2 x]])". I had the idea to use a KroneckerDelta as following but it does not work !

X[x_, y_] = KroneckerDelta[1/2 (ArcCos[1 - Cos[2 x]]), y]

DensityPlot[Sin[x] Sin[y]*X[x, y], {x, -Pi/4, Pi/4}, {y, -Pi/4, Pi/4},ColorFunction -> "SunsetColors", PlotLegends -> Automatic]

enter image description here

Any idea why this is not working and how to rectify ?

Thank you for your time !

Geoff

$\endgroup$
3
  • $\begingroup$ DensityPlot is not meant to be used for drawing curves. $\endgroup$
    – shrx
    Commented Mar 27, 2015 at 10:55
  • $\begingroup$ Since KroneckerDelta is in effect "infinitely thin," DensityPlot can't locate where it is nonzero. $\endgroup$ Commented Mar 27, 2015 at 13:20
  • $\begingroup$ Ok I understand the problem ! $\endgroup$ Commented Mar 27, 2015 at 17:26

1 Answer 1

3
$\begingroup$

If you want a curve whose shape is determined by y = 1/2 (ArcCos[1 - Cos[2 x]]) and whose color is determined by Sin[x] Sin[y], you may use

Plot[1/2 (ArcCos[1 - Cos[2 x]]), {x, -\[Pi]/4, \[Pi]/4}, 
ColorFunction -> Function[{x, y}, ColorData["SunsetColors"][Sin[x] Sin[y]]]]

enter image description here

$\endgroup$
0

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.