plotting - can the color in MeshStyle be specified by a ColorFunction, such as "SunsetColors" for example. If so, what is the correct syntax?
This is an example given in Help:
Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, MeshStyle -> Gray]
Could this be changed to something like
Plot3D[Sin[x y], {x, 0, 3}, {y, 0, 3}, MeshStyle -> "SunsetColors"]
The above line does not work, but is there a way to modify syntax so that "SunsetColors"
can be used?
Answer
Here is the method you posted as an answer yourself, condensed by exploiting repetitious code.
Module[{a, d, t, p, kx, ky, func, cf, plot1, plot2},
a = 1.42; d = a Sqrt[3]; t = 2.8; p = 25;
func := t Sqrt[3 + 2 Cos[a kx] + 4 Cos[a/2 kx] Cos[d/2 ky]];
cf[1] = ColorData["SunsetColors", #3] &;
cf[-1] = ColorData["SunsetColors", 1 - #3] &;
plot1 = Plot3D[#3 func, {#, -2 Pi / a, 2 Pi / a}, {#2, -2 Pi / a, 2 Pi / a},
ColorFunction -> cf[#3], BoundaryStyle -> None, Mesh -> None, PlotPoints -> p] &;
plot2 = ParametricPlot3D[
Table[{kx, ky, #3 func}, {#2, -2 Pi / a, 2 Pi / a, 1/2}],
{#, -2 Pi / a, 2 Pi / a}, ColorFunction -> cf[#3],
PlotStyle -> Directive[Thickness[0.002]], PlotPoints -> p] &;
Show[
plot1[kx, ky, #] & /@ {1, -1},
plot2[kx, ky, #] & /@ {1, -1},
plot2[ky, kx, #] & /@ {1, -1},
PlotRange -> All,
BoxRatios -> {1, 0.75, 0.75},
AxesLabel ->
Map[Style[#, Large, Bold] &, {Subscript[k, x], Subscript[k, y], Ε[OverVector[k]]}],
ImageSize -> {800, 800},
ViewPoint -> {-3, -2, 0}
]
]
Comments
Post a Comment