I am trying to create a 3D density plot and use LaTeX to render the axis labels. My code is below. When I comment out the AxesLabel command the code runs fine and, in particular, MaTeX renders the legend label correctly. What am I doing wrong?
<< MaTeX`
texStyle = {FontFamily -> "Latin Modern Roman", FontSize -> 15, Black};
f[x_, y_, z_] := Cos[x] Cos[y] Cos[z]
DensityPlot3D[
f[x, y, z],
{x, 0, 2 \[Pi]},
{y, 0, 2 \[Pi]},
{z, 0, 2 \[Pi]},
AxesLabel\[Rule]{MaTeX["x"],MaTeX["y"],MaTeX["z"]},
LabelStyle -> texStyle,
PlotLegends -> BarLegend[
Automatic,
LegendMarkerSize -> 300,
LegendLabel -> MaTeX["f(\\vec{x})", Magnification -> 2]]
]
When I try to run it, I get these errors:
ReplacePart::reps: {1->x,2->y,5,2->y,2->y,2->y,5,2->y,3->z,2->y,<<2>>} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.
ReplacePart::reps: {1->6.28318,2->6.28318,5,2->6.28318,2->6.28318,2->6.28318,5,2->6.28318,3->6.28318,2->6.28318,<<2>>} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.
DensityPlot3D
itself and not MaTeX.ClearAll[f, x, y, z]; f[x_, y_, z_] := Cos[x] Cos[y] Cos[z]; labels = {MaTeX["x"], MaTeX["y"], MaTeX["z"]};
and nowDensityPlot3D[ f[x, y, z], {x, 0, 2 \[Pi]}, {y, 0, 2 \[Pi]}, {z, 0, 2 \[Pi]}, AxesLabel -> labels]
gives error, butContourPlot3D[ f[x, y, z], {x, 0, 2 \[Pi]}, {y, 0, 2 \[Pi]}, {z, 0, 2 \[Pi]}, AxesLabel -> labels]
works. $\endgroup$