# DensityPlot and KroneckerDelta

I have the following DensityPlot:

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


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]


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

Thank you for your time !

Geoff

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

## 1 Answer

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