TL, DR: Use the LightingAngle
option to DensityPlot
to achieve the same shadows effect as ReliefPlot
. (@Brett Champion's answer)
To plot bivariate functions, we typically either use Plot3D
, whose dynamic effects allow flexible investigation, or DensityPlot
, which is better for publications. However, sometimes the output of DensityPlot
is a little ... obscure(?), and shadows from ReliefPlot
would add a lot perspective.
Example from the
ReliefPlot
documentation:ReliefPlot[Table[i + Sin[i^2 + j^2], {i, -4, 4, .03}, {j, -4, 4, .03}], ColorFunction -> "SunsetColors"]
Compare a replication using
DensityPlot
:DensityPlot[i + Sin[i^2 + j^2], {i, -4, 4}, {j, -4, 4}, ColorFunction -> "SunsetColors", PlotPoints -> 40]
Where the well-known oddity ofReliefPlot
's orientation can be seen.
For years on MMA SE, a lot of members have used ReliefPlot
via manual sampling
for function plotting questions
(e.g., this post),
yielding better aesthetic results.
Alternatives include:
- Using
Plot3D
and set the viewpoint at infinity above, but it can also hairy to do. (See @MichaelE2's answer which does this elegantly) - Manually define normal vectors and do a normal mapping, which I am not sure how to implement in Mathematica right now. (See my answer to get a crude idea)
But why isn't ReliefPlot
for functions been officially implemented
(i.e., with adaptive sampling like other *Plot*
built-ins)?
What is the real technical difficulty?
P.S.: I believe extensive about this problem can already be found on MMA SE (like here and here), but they are scattered everywhere so I am raising this question as a port.
For this thread to serve as a guide to others with the same problem,
what are the ways to mimick ReliefPlot
's texture?
(please provide simple code and output examples)
From your personal experience,
at what point should one bother to do this for the nicer touch?