0
$\begingroup$

I have started using MaTeX (excellent package to integrate Latex in your wonderful Mathematica generated plots).

I am getting a warning in generating the following plot

<< MaTeX`
texStyle = {FontFamily -> "Latin Modern Roman", FontSize -> 18};
SetOptions[MaTeX, 
  "Preamble" -> {"\\usepackage{wasysym}\\usepackage[dvipsnames]{xcolor}"}];
f[x_] := ScientificForm[
  N[x /. {NumberForm[y_, {w_, z_}] :> ScientificForm[y, 2]}], 2]
DensityPlot[Sin[x y], {x, -2, 2}, {y, -2, 2}, 
 ColorFunction -> ColorData[{"RedBlueTones", "Reverse"}], 
 ImageSize -> {500, Automatic}, PlotRange -> All, 
 PlotLegends -> 
  Placed[BarLegend[Automatic, LegendFunction -> f, 
    LegendMarkerSize -> 350, 
    LegendLabel -> 
     MaTeX["\\mathrm{Re}(\\mathrm{i}\,I_{\\overline{\\mathrm{D}3}}/L^\
3 T)", Magnification -> 2], LabelStyle -> texStyle], {After, Top}], 
 BaseStyle -> texStyle]
Clear[f]

I know that the problem is in using the LegendFunction and the "\\overline" (when I remove one of the two, no warning is issued).

$\endgroup$
3
  • $\begingroup$ This is due to f (the LegendFunction) corrupting the Graphics expression returned by MaTeX. Since this function does not seem to do anything here anyway, remove it. $\endgroup$
    – Szabolcs
    Commented Mar 15, 2021 at 13:00
  • $\begingroup$ Thanks for the reply Szabolcs, however the function f is indeed doing something there. It is ensuring that the legend comes out in Scientific form, and I would like to keep that. $\endgroup$
    – user12588
    Commented Mar 16, 2021 at 15:00
  • $\begingroup$ This is a very crude way to try to change tick marks that affects all numbers within the expression, not just ticks (and is very likely to break something). I suggest you use this way instead: mathematica.stackexchange.com/a/149416/12 $\endgroup$
    – Szabolcs
    Commented Mar 16, 2021 at 15:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.