iis服务器助手广告广告
返回顶部
首页 > 资讯 > 精选 >怎么用R语言绘图时实现输出希腊字符上下标及数学公式
  • 812
分享到

怎么用R语言绘图时实现输出希腊字符上下标及数学公式

2023-06-25 13:06:18 812人浏览 八月长安
摘要

这篇文章主要讲解了“怎么用R语言绘图时实现输出希腊字符上下标及数学公式”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么用R语言绘图时实现输出希腊字符上下标及数学公式”吧!希腊字母使用希腊字

这篇文章主要讲解了“怎么用R语言绘图时实现输出希腊字符上下标及数学公式”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么用R语言绘图时实现输出希腊字符上下标及数学公式”吧!

希腊字母

使用希腊字符、上标、下标及数学公式,都需要利用一个函数:expression(),具体使用方式如下:

plot(cars)title(main = expression(Sigma))

上下标

expression()中的下标为[],上标为^,空格为~,连接符为*。示例代码如下:

plot(cars)title(main = expression(Sigma[1]~'a'*'n'*'d'~Sigma^2))

paste

想达到上面的效果,我们其实可以使用paste()expression()进行组合,不需要上述繁琐的过程,也能够达到我们上述一模一样的输出,并且方便快捷:

plot(cars)title(main = expression(paste(Sigma[1], ' and ', Sigma^2)))

一个复杂的例子

目标:

怎么用R语言绘图时实现输出希腊字符上下标及数学公式

代码:

expression(paste((frac(1, m)+frac(1, n))^-1, ABCD[paste(m, ',', n)]))

进阶

在我们想批量产生大量含有不同变量值的标题时,如果遇到变量与公式的混合输出该如何操作,

可参考前文:R语言绘图公式与变量对象混合拼接实现方法

数学公式

最后的数学公式,只需要在expression()中进行相应的符号连接即可

具体要求可参考:Mathematical Annotation in R

鉴于其很不稳定,这里将里面的细节搬运过来。

(下表也可以直接在 R help 中搜索 plotmath 获取。)

SyntaxMeaning
x + yx plus y
x - yx minus y
x*yjuxtapose x and y
x/yx forwardslash y
x %±% yx plus or minus y
x %/% yx divided by y
x %*% yx times y
x %.% yx cdot y
x[i]x subscript i
x^2x superscript 2
paste(x, y, z)juxtapose x, y, and z
sqrt(x)square root of x
sqrt(x, y)yth root of x
x == yx equals y
x != yx is not equal to y
x < yx is less than y
x <= yx is less than or equal to y
x > yx is greater than y
x >= yx is greater than or equal to y
!xnot x
x %~~% yx is approximately equal to y
x %=~% yx and y are congruent
x %==% yx is defined as y
x %prop% yx is proportional to y
x %~% yx is distributed as y
plain(x)draw x in nORMal font
bold(x)draw x in bold font
italic(x)draw x in italic font
bolditalic(x)draw x in bolditalic font
symbol(x)draw x in symbol font
list(x, y, z)comma-separated list
ellipsis (height varies)
cdotsellipsis (vertically centred)
ldotsellipsis (at baseline)
x %subset% yx is a proper subset of y
x %subseteq% yx is a subset of y
x %notsubset% yx is not a subset of y
x %supset% yx is a proper superset of y
x %supseteq% yx is a superset of y
x %in% yx is an element of y
x %notin% yx is not an element of y
hat(x)x with a circumflex
tilde(x)x with a tilde
dot(x)x with a dot
ring(x)x with a ring
bar(xy)xy with bar
widehat(xy)xy with a wide circumflex
widetilde(xy)xy with a wide tilde
x %<->% yx double-arrow y
x %->% yx right-arrow y
x %<-% yx left-arrow y
x %up% yx up-arrow y
x %down% yx down-arrow y
x %<=>% yx is equivalent to y
x %=>% yx implies y
x %<=% yy implies x
x %dblup% yx double-up-arrow y
x %dbldown% yx double-down-arrow y
alpha – omegaGreek symbols
Alpha – Omegauppercase Greek symbols
theta1, phi1, sigma1, omega1cursive Greek symbols
Upsilon1capital upsilon with hook
alephfirst letter of Hebrew alphabet
infinityinfinity symbol
partialdiffpartial differential symbol
nablanabla, gradient symbol
32*degree32 degrees
60*minute60 minutes of angle
30*second30 seconds of angle
displaystyle(x)draw x in normal size (extra spacing)
textstyle(x)draw x in normal size
scriptstyle(x)draw x in small size
scriptscriptstyle(x)draw x in very small size
underline(x)draw x underlined
x ~~ yput extra space between x and y
x + phantom(0) + yleave gap for “0”, but don't draw it
x + over(1, phantom(0))leave vertical gap for “0” (don't draw)
frac(x, y)x over y
over(x, y)x over y
atop(x, y)x over y (no horizontal bar)
sum(x[i], i==1, n)sum x[i] for i equals 1 to n
prod(plain§(X==x), x)product of P(X=x) for all values of x
integral(f(x)*dx, a, b)definite integral of f(x) wrt x
uNIOn(A[i], i==1, n)union of A[i] for i equals 1 to n
intersect(A[i], i==1, n)intersection of A[i]
lim(f(x), x %->% 0)limit of f(x) as x tends to 0
min(g(x), x > 0)minimum of g(x) for x greater than 0
inf(S)infimum of S
sup(S)supremum of S
x^y + znormal operator precedence
x^(y + z)visible grouping of operands
x^{y + z}invisible grouping of operands
group("(",list(a, b),"]")specify left and right delimiters
bgroup("(",atop(x,y),")")use Scalable delimiters
group(lceil, x, rceil)special delimiters
group(lfloor, x, rfloor)special delimiters

感谢各位的阅读,以上就是“怎么用R语言绘图时实现输出希腊字符上下标及数学公式”的内容了,经过本文的学习后,相信大家对怎么用R语言绘图时实现输出希腊字符上下标及数学公式这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是编程网,小编将为大家推送更多相关知识点的文章,欢迎关注!

--结束END--

本文标题: 怎么用R语言绘图时实现输出希腊字符上下标及数学公式

本文链接: https://www.lsjlt.com/news/304957.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • 怎么用R语言绘图时实现输出希腊字符上下标及数学公式
    这篇文章主要讲解了“怎么用R语言绘图时实现输出希腊字符上下标及数学公式”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么用R语言绘图时实现输出希腊字符上下标及数学公式”吧!希腊字母使用希腊字...
    99+
    2023-06-25
  • R语言绘图时输出希腊字符上下标及数学公式实现方法
    目录希腊字母上下标paste一个复杂的例子进阶数学公式通常在我们写论文时,所需要的统计图是非常严谨的,里面的希腊字符与上下脚标都必须要严格书写。因此在使用R绘图时,如何在我们目标图中...
    99+
    2024-04-02
  • 怎么用R语言绘图实现公式与变量对象混合拼接
    本篇内容主要讲解“怎么用R语言绘图实现公式与变量对象混合拼接”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么用R语言绘图实现公式与变量对象混合拼接”吧!当我们在R中进行绘图时,如果涉及到数学或...
    99+
    2023-06-25
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作