What should I do to have R correctly show in a legend the equivalent to this latex expression?
\alpha \leq \beta
The following commands handle \alpha and \beta correctly, but not the \leq symbol:
expression(paste(alpha, " leq ", beta))
expression(paste(alpha, " <= ", beta))
You can add two or more legends to a plot, just running the legend function multiple times with different arguments. In the following example we are going to add two more Bessel functions and add a new legend for them. Note that you can also add more legends outside the plot, in case the legends doesn’t fit inside the layout.
TeX converts a string comprising LaTeX commands (such as a math equation) to a plotmath expression. Plotmath expressions can be used throught R's graphic system to represent formatted text and equations. TeX ( input, bold = FALSE, italic = FALSE, user_defined = list (), output = c ("expression", "character", "ast") )
A LaTeX command that matches one of the names is translated into the corresponding string and included in the final plotmath expression. The file symbols.R in the source code of this package contains one such table that can be used as a reference. The template string can include one of the following special template parameters:
In order to change the legend size in R you can make use of the cex argument. Values bigger than 1 will lead to a bigger legend and smaller to smaller legends than the default.
Just use
expression(alpha <= beta)
For more info check out
?plotmath
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With