在R中表达 [英] Expression in R

查看:141
本文介绍了在R中表达的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在R中绘制时,我想使用表达式作为我的 ylab = 。如何获取字符,使用表达式使用 \mathcal {} 风格字体?我正在运行Ubuntu,我不想使用ggplot。

I want to use expression for my ylab= when plotting in R. How do I get characters, using expression using the \mathcal{} style font? I am running Ubuntu and I don't want to use ggplot.

要澄清: ylab 的一部分将包含数学角色,其中一部分不会(并将是一个公式)。这就是为什么我想使用表达式
这是我想要的这个符号:
= \mathcal {E}

To clarify: part of the ylab will contain mathcal characters and part of it will not (and will be a formula). That's why I want to use expression It is this symbol which I want: = \mathcal{E}

推荐答案

解决方案是使用 tikz ,这是一个非常棒的例子,这是一个比他们在函数 tikzDevide的帮助下生成的示例更不美丽的例子: :tikz

One possible solution is to use tikz, which is kind of awesome, here is a much less beautiful example than the one they generate in the help of function tikzDevide::tikz:

require(filehash)
require(tikzDevice)

tikz("sinhplot.tex", width = 8, height = 4, 
     standAlone = TRUE,
     packages = c("\\usepackage{tikz}",
                  "\\usepackage[active,tightpage,psfixbb]{preview}",
                  "\\PreviewEnvironment{pgfpicture}",
                  "\\setlength\\PreviewBorder{0pt}",
                  "\\usepackage{amssymb}")
plot(sinh, col="steelblue", lwd=2, xlim=c(-3,3), xlab="$\\mathcal E= [-3 , 3]$")
grid()
dev.off()

tools::texi2dvi(sinhplot,pdf=T)
system(paste(getOption('pdfviewer'),'sinhplot.pdf'))

结果看起来很不错!

The result looks quite nice!

另一个解决方案是放弃在你的数字标签中有美丽的人物...

Another solution is to just give up having beautiful characters in the labels of your figures...

这篇关于在R中表达的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆