2
$\begingroup$

I would like to have the expression $$\rho\!\begin{pmatrix}a&b\\ c & d\end{pmatrix}=1$$ as a legend of a plot. When I try (code is adapted from this answer)
Plot[x^2, {x, 0, 1}, PlotLegends -> Placed[{Text[Style[ToExpression["\\rho\\left({{1/(p-1),1/(p-1)},{2/(q-1),0}}\\right)=1",TeXForm, HoldForm], Bold]]}, {.4, .8}]]

I obtain the following:
enter image description here
which is not what I want...

I tried using MaTex but had trouble installing it (in the configuration step)...

Is there a simple way to fix my issue?

$\endgroup$
4
$\begingroup$
eqn = HoldForm[ ρ MatrixForm[{{a, b}, {c, d}}] == 1];

Plot[x^2, {x, 0, 1},
 PlotLegends -> Placed[{Style[eqn, Bold]}, {.4, .8}]]

enter image description here

$\endgroup$
4
$\begingroup$

Using MaTeX

Needs["MaTeX`"]
pl=HoldForm[p {{a,b},{c,d}}==1];
plt=MaTeX[TeXForm@pl,Magnification->1.5];
Plot[x^2,{x,0,1},PlotLegends->Placed[plt,{.4,.8}]]

Mathematica graphics

To use rho in place of p, you can try replacing the p (since only one of them happen to be there in this example)

pl=HoldForm[p {{a,b},{c,d}}==1];
plt=ToString@TeXForm@pl;
plt=MaTeX[StringReplace[plt,"p"->"\\rho"],Magnification->1.7];
Plot[x^2,{x,0,1},PlotLegends->Placed[plt,{.4,.8}]]

Mathematica graphics

$\endgroup$
  • 1
    $\begingroup$ Actually the ToString@TeXForm[...] is not necessary. This is done automatically by MaTeX. Just writing pl instead is sufficient. $\endgroup$ – Szabolcs Jul 6 '17 at 4:12
  • 1
    $\begingroup$ @Szabolcs thanks. I did not know this. Changed the first example. But for the second example, I still need ToString I think, since I needed to do StringReplace later on. $\endgroup$ – Nasser Jul 6 '17 at 4:17
2
$\begingroup$

Maybe

pl = p {{a, b}, {c, d}} == 1 // HoldForm // TraditionalForm // 
   Rasterize[#, RasterSize -> 500] & // Magnify[#, 1] &;

Plot[x^2, {x, 0, 1}, PlotLegends -> Placed[pl, {.4, .8}]]

enter image description here

$\endgroup$
  • $\begingroup$ Looks good :), thank you very much. The only little details is that the "p" is not a $p$ but a rho $\rho$. Is it possible to also include that or it would make the solution much more complicated? $\endgroup$ – Surb Jul 5 '17 at 22:02
  • $\begingroup$ Instead of the "normal" p just input esc rho esc $\endgroup$ – eldo Jul 5 '17 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.