Closed caijun closed 6 years ago
Hi caijun, I can add support for that. In the meantime, you should be able to simply use \n
to force a newline.
I tried \n
, but it didn't work.
library(plyr)
library(ggplot2)
x <- seq(0, 4, length.out=100)
alpha <- 1:5
data <- mdply(alpha, function(a, x) data.frame(v=a*x^a, x=x), x)
p <- ggplot(data, aes(x=x, y=v, color=X1)) +
geom_line() +
ylab(TeX('$\\alpha x^\\alpha$, where $\\alpha \\in 1\\ldots 5$')) +
ggtitle(TeX('Using $\\LaTeX$ for plotting in ggplot2. \n I $\\heartsuit$ ggplot!')) +
coord_cartesian(ylim=c(-1, 10)) +
guides(color=guide_legend(title=NULL)) +
scale_color_discrete(labels=lapply(sprintf('$\\alpha = %d$', alpha), TeX))
print(p)
I would like to add a line break in the plot title using the LaTeX command
\newline
, however it didn't produce the figure as expectation.