绘图轴标题上的特殊字符和上标 [英] Special characters and superscripts on plot axis titles

查看:93
本文介绍了绘图轴标题上的特殊字符和上标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个带有特殊字符和上标的y轴标题.我能够做到这一点,但我希望不要在右括号上加上上标.这就是我遇到的问题.我认为这只是放置括号的地方,但是我已经(似乎)尝试了所有操作.

I am trying to make a y-axis title with both a special character and a superscript. I am able to do this, but I want the closing parentheses not to be superscripted. And that's what I'm having a problem with. I think its just a placing of my parenthesis, but I've tried (seemingly) everything.

plot(WatexCl, ConcuM, col = as.numeric(1), pch = as.numeric(Depth), 
   xlab = expression(paste("Concentration Cl  ( ", mu, "moles/g dry wt)")), 
   ylab = expression(paste("Average Conc of S- on plates ( ", mu, "Moles/cm"^"2"),)), 
   data = plates)

推荐答案

用户经常无法理解的一件事是,当在表达式中使用字符串时,您总是不需要将字符串加引号并将paste一起使用情节标签.直接使用布局工具(例如~*)通常更简单.例如:

The one thing that often users fail to grasp is that you invariably don't need to quote strings and paste them together when used in an expression for a plot label. It is usually simpler to use the layout tools directly (e.g. ~ and *). For example:

df <- data.frame(y = rnorm(100), x = rnorm(100))

plot(y ~ x, data = df,
     ylab = expression(Average ~ Conc ~ of ~ S- ~ on ~ plates ~ 
                       (mu ~ Moles ~ cm^{-2} ~ dry ~ wt)),
     xlab = expression(Concentration ~ Cl ~ (mu ~ moles ~ g^{-1} ~ dry ~ wt)))

或者,您可以包含用于较长文本段的字符串;在这种情况下,可以说很容易做到:

Alternatively, you can include strings for longer sections of text; in this case it is arguably easier to do:

plot(y ~ x, data = df,
     ylab = expression("Average Conc of S- on plates" ~
                         (mu ~ moles ~ cm^{-2} ~ "dry wt")),
     xlab = expression("Concentration Cl" ~ (mu ~ moles ~ g^{-1} ~ "dry wt")))

但是请注意,这里不需要paste字符串和其他功能.

but note there is no need to paste strings and other features here.

两种产品:

请注意plotmath带有上标2的问题.您可能希望为y轴边距添加一些额外的空间,以适应以下情况:

Note the issue plotmath has with the superscript 2. You may wish to add some extra space for the y-axis margin to accommodate that:

op <- par(mar = c(5,4.5,4,2) + 0.1)
plot(y ~ x, data = df,
     ylab = expression("Average Conc of S- on plates" ~
                          (mu ~ moles ~ cm^{-2} ~ "dry wt")),
     xlab = expression("Concentration Cl" ~ (mu ~ moles ~ g^{-1} ~ "dry wt")))
par(op)

生产

这篇关于绘图轴标题上的特殊字符和上标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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