怎么用R语言绘图时实现输出希腊字符上下标及数学公式
发表于:2025-11-18 作者:千家信息网编辑
千家信息网最后更新 2025年11月18日,这篇文章主要讲解了"怎么用R语言绘图时实现输出希腊字符上下标及数学公式",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"怎么用R语言绘图时实现输出希腊字符
千家信息网最后更新 2025年11月18日怎么用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)))
一个复杂的例子
目标:
代码:
_expression(paste((frac(1, m)+frac(1, n))^-1, ABCD[paste(m, ',', n)]))
进阶
在我们想批量产生大量含有不同变量值的标题时,如果遇到变量与公式的混合输出该如何操作,
可参考前文:R语言绘图公式与变量对象混合拼接实现方法
数学公式
最后的数学公式,只需要在_expression()中进行相应的符号连接即可
具体要求可参考:Mathematical Annotation in R
鉴于其很不稳定,这里将里面的细节搬运过来。
(下表也可以直接在 R help 中搜索 plotmath 获取。)
| Syntax | Meaning |
|---|---|
| x + y | x plus y |
| x - y | x minus y |
| x*y | juxtapose x and y |
| x/y | x forwardslash y |
| x %±% y | x plus or minus y |
| x %/% y | x divided by y |
| x %*% y | x times y |
| x %.% y | x cdot y |
| x[i] | x subscript i |
| x^2 | x 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 == y | x equals y |
| x != y | x is not equal to y |
| x < y | x is less than y |
| x <= y | x is less than or equal to y |
| x > y | x is greater than y |
| x >= y | x is greater than or equal to y |
| !x | not x |
| x %~~% y | x is approximately equal to y |
| x %=~% y | x and y are congruent |
| x %==% y | x is defined as y |
| x %prop% y | x is proportional to y |
| x %~% y | x 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) |
| cdots | ellipsis (vertically centred) |
| ldots | ellipsis (at baseline) |
| x %subset% y | x is a proper subset of y |
| x %subseteq% y | x is a subset of y |
| x %notsubset% y | x is not a subset of y |
| x %supset% y | x is a proper superset of y |
| x %supseteq% y | x is a superset of y |
| x %in% y | x is an element of y |
| x %notin% y | x 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 %<->% y | x double-arrow y |
| x %->% y | x right-arrow y |
| x %<-% y | x left-arrow y |
| x %up% y | x up-arrow y |
| x %down% y | x down-arrow y |
| x %<=>% y | x is equivalent to y |
| x %=>% y | x implies y |
| x %<=% y | y implies x |
| x %dblup% y | x double-up-arrow y |
| x %dbldown% y | x double-down-arrow y |
| alpha - omega | Greek symbols |
| Alpha - Omega | uppercase Greek symbols |
| theta1, phi1, sigma1, omega1 | cursive Greek symbols |
| Upsilon1 | capital upsilon with hook |
| aleph | first letter of Hebrew alphabet |
| infinity | infinity symbol |
| partialdiff | partial differential symbol |
| nabla | nabla, gradient symbol |
| 32*degree | 32 degrees |
| 60*minute | 60 minutes of angle |
| 30*second | 30 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 ~~ y | put extra space between x and y |
| x + phantom(0) + y | leave 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 + z | normal 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语言绘图时实现输出希腊字符上下标及数学公式这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!
公式
下标
数学
希腊
输出
字符
语言
绘图
学习
上标
代码
内容
变量
参考
混合
不同
复杂
繁琐
一模一样
希腊字母
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
我们为什么要学网络安全法
传感器数据数据库
强化网络安全和信息化建设
服务器木马php
网络技术有限公司世界排名
外网访问本地服务器
互联网总决赛西南科技大学
怎么在word导入数据库中
绝地求生服务器卡设置
小孩子起名软件开发
软件开发工程师是it吗
关于后台开发数据库表
易方达做软件开发好吗
兴化大型网络技术参考价格
数据库1013报错
spring数据库慢
湖州市网络安全教育平台
魔兽世界单机版数据库卸载
梦幻之乡服务器的英文
网络安全违规约谈
软件开发通常有哪些功能模块
软件开发 技术栈 paas
es文件管理器建服务器
万得易通软件开发好不好
网络安全等保申请
滨州考勤管理hr软件开发公司
数据库语言通用吗
苏州调度服务器价格
天津网络技术服务供应商
个人电脑软件开发支付平台