0
$\begingroup$

Maybe this is a bit of trivial question, but here goes. I often think it is convenient to label a plot legend with an actual function - especially if it is a fit to some data or something.

Typically I will use something like:

PlotLegends ->Placed[{"y = mx + c"}, {Left, 0.86}, Pane[#, 450, Alignment ->Left] &]

Or make use of HoldForm[...] if I need pieces of the equation to look a certain way.

Which will work, but often renders in a way that the subscripts, in particular will merged with the fraction line/bar.

Does anyone have a better way of representing equations and formulae in a plot legend. Perhaps there is a way to use LaTeX?

$\endgroup$
  • 1
    $\begingroup$ Have you seen PlotLegends -> "Expressions"? $\endgroup$ – b3m2a1 Mar 14 '17 at 18:47
  • 1
    $\begingroup$ ...or TraditionalForm..., e.g., PlotLegends -> TraditionalForm[y = Subscript[m , 1] x + b]. $\endgroup$ – David G. Stork Mar 14 '17 at 18:55
  • 2
    $\begingroup$ If you really want to insert LaTeX, you might want to check out MaTeX. $\endgroup$ – jjc385 Mar 14 '17 at 19:06
  • $\begingroup$ Ah great! I didn't know about these functions - thanks all! $\endgroup$ – Q.P. Mar 14 '17 at 22:28

Your Answer

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

Browse other questions tagged or ask your own question.