How to show $ \ {X_t \} $ in the chart name R

How to show $ \ {X_t \} $ latex in the name of the graph R?

for instance

plot(slot(x,"GRID"),slot(x,"PATH"),type="l", xlab="Time t",ylab="X", main=paste("Simulation of \{X_t\}")) 

Thanks!

+4
source share
3 answers

Assuming you provide meaningful arguments for slot expressions, I think there is a reasonable chance that this is what you want:

 plot(1:10,1:10,type="l", xlab="Time t",ylab="X", main=expression("Simulation of {"*X[t]*"}")) 

This is a plotmath expression that represents "t" as the index of "X", and this expression is enclosed in braces. If I didn’t read your query correctly, then note that the “*” character is a delimiter in the plotmath syntax, and curly braces are just characters that can be removed. (LaTeX expressions don't really matter to those of us who just use the plotmath syntax, so describing what you want in prose or mathematical jargon will work better for any clarification.)

+9
source

To R-emulate the LaTeX layout set, see the examples and methods described in ?plotmath .

To actually LaTeX type your story, use the tikz() graphics device provided by the tikzDevice package.

+6
source

The group() function plotmath can be used to formalize a DWin response. The advantage of this solution (IMHO) is that it does not use strings as part of the expression. Instead, we use the ~ operator to add an interval (spaces are ignored).

 plot(1:10, 1:10, type = "l", xlab = "Time t", ylab = "X", main=expression(Simulation ~ of ~ group("{", X[t], "}"))) 

The bgroup() function plotmath provides scalable delimiters, but it is used in the same way as the sample code above.

Edit (in response to run2 comment): The same approaches can be used in ggplot and lattice, using the power of plotmath, just like with basic graphics. For instance.

 require(ggplot2) df <- data.frame(A = 1:10, B = 1:10) qplot(A, B, data = df, main = expression(Simulation ~ of ~ group("{", X[t], "}"))) 
+4
source

All Articles