5
$\begingroup$

In the documentation of ColorData I found this esthetically beautiful image created by ReliefPlot.

ReliefPlot[
 Table[RandomReal[] (Sin[x + y^2] + Sin[x^2 + 3 y]), {x, -3, 
   3, .01}, {y, -3, 3, .01}], 
 ColorFunction -> ColorData["SouthwestColors"]]

enter image description here

But if we do not use RandomReal[] in the code we get this:

ReliefPlot[
 Table[(Sin[x + y^2] + Sin[x^2 + 3 y]), {x, -3, 3, .01}, {y, -3, 
   3, .01}], ColorFunction -> ColorData["SouthwestColors"]]

enter image description here

Color gradient "SouthwestColors" contains quite different colors. For example there is no black color nevertheless we can see random black grain the the first image.

Also in the first image we see nice curves of light brown color (also a circle) but on the second image we can not see any apparent curves.

I have two question:

  1. What is the cause of changes in colors of color scheme? (evidently the cause is using RandomReal[] but I need explanation why)

  2. What is the cause of appearing of the curves?

$\endgroup$

2 Answers 2

4
$\begingroup$

(1.) The darkening (and hence the black color) comes from the shadowing. ReliefPlot isn't the same as DensityPlot; it plots the surface as if there was a light coming from a certain direction (see LightingAngle).

For example, compare:

ReliefPlot[Table[Sin[i^2 + j^2], {i, -4, 4, .05}, {j, -4, 4, .05}], 
 ColorFunction -> (Red &)]

DensityPlot[Sin[i^2 + j^2], {i, -4, 4}, {j, -4, 4}, ColorFunction -> (Red &)]

DensityPlot is uniformly red, as given by the ColorFunction, but ReliefPlot is not.

(2.) The curves are visibles also on your second image. They are just more pronounced on the first because you are using a multiplicative noise, and the curves are actually the 0 contours of the function. Hence, the noise doesn't have any effect on them. Try with additive noise (RandomReal[] + (Sin[x + y^2] + Sin[x^2 + 3 y])), and they will not be so prominent anymore.

$\endgroup$
3
  • $\begingroup$ But the 0 contour should be 0.5 for the color function and, yes, this color is light brown. But if we multiply it by random number in interval (0,1) we get random color in interval (0,0.5) so I do not understand why the 0 contour should have constant color? It should oscillate in the same interval (0,0.5), no? $\endgroup$ Commented Mar 13 at 14:57
  • $\begingroup$ If you multiply 0 with whatever number, it remains 0 ... Also, use ListDensityPlot to remove the effects of shadowing and get a better view of what is going on: ListDensityPlot[Table[RandomReal[] (Sin[x + y^2] + Sin[x^2 + 3 y]), {x, -3, 3, .05}, {y, -3, 3, .05}], ColorFunction -> ColorData["SouthwestColors"], PlotLegends -> Automatic] $\endgroup$
    – Domen
    Commented Mar 13 at 15:02
  • $\begingroup$ I got it wrong. I was thinking as if the randomness took place on the color function value 0.5. But it is that the value 0 of the function remains always 0 and then it is always mapped to the color function 0.5. $\endgroup$ Commented Mar 13 at 16:04
3
$\begingroup$
  • A comment.

  • We can compare with the 3D and 2D. We note that the data have expand to the range {{0,600}, {0,600}}.

  • 3D view of the ReliefPlot.

ListPlot3D[
 Table[RandomReal[]  (Sin[x + y^2] + Sin[x^2 + 3  y]), {x, -3, 
   3, .01}, {y, -3, 3, .01}], 
 ColorFunction -> ColorData["SouthwestColors"], ViewPoint -> Top, 
 ViewProjection -> "Orthographic"]

enter image description here enter image description here

  • Compare with 2D contours with ReliefPlot.
ListContourPlot[
 Table[RandomReal[] (Sin[x + y^2] + Sin[x^2 + 3  y]), {x, -3, 
   3, .01}, {y, -3, 3, .01}], Contours -> {0}]

enter image description here

  • When we set LightingAngle -> None in ReliefPlot,then with or without the terms of the RandomReal[],the color theme are the same.
{ReliefPlot[
  Table[RandomReal[]  (Sin[x + y^2] + Sin[x^2 + 3  y]), {x, -3, 
    3, .01}, {y, -3, 3, .01}], 
  ColorFunction -> ColorData["SouthwestColors"], 
  LightingAngle -> None], 
 ReliefPlot[
  Table[(Sin[x + y^2] + Sin[x^2 + 3  y]), {x, -3, 3, .01}, {y, -3, 
    3, .01}], ColorFunction -> ColorData["SouthwestColors"], 
  LightingAngle -> None]}

enter image description here

$\endgroup$
1
  • $\begingroup$ This is a nice demonstration of the effect. (+1) $\endgroup$ Commented Mar 13 at 16:09

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.