hi there, I find the following codes produce strange output. plot(1:10, xlab = expression(NO[3]^-~(mg/L))) you will notice that the unit, mg/L is in superscript format. That means that "~" is not for space. However, the help page of plotmath does not mention this behavior. Best, Jinsong [[alternative HTML version deleted]]
FYI I see everything after the '^' as a superscript. The '~' does act as a space. (When I omit it there is less space between the '-' and the '('. On Mon, May 21, 2018 at 3:09 PM, Jinsong Zhao <jszhao at yeah.net> wrote:> hi there, > > I find the following codes produce strange output. > > plot(1:10, xlab = expression(NO[3]^-~(mg/L))) > > you will notice that the unit, mg/L is in superscript format. > That means that "~" is not for space. > However, the help page of plotmath does not mention this behavior. > > Best, > Jinsong > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Try plot(1:10, xlab = expression(NO[3]^{'-'}~(mg/L))) Hope this helps, Rui Barradas On 5/21/2018 1:09 PM, Jinsong Zhao wrote:> hi there, > > I find the following codes produce strange output. > > plot(1:10, xlab = expression(NO[3]^-~(mg/L))) > > you will notice that the unit, mg/L is in superscript format. > That means that "~" is not for space. > However, the help page of plotmath does not mention this behavior. > > Best, > Jinsong > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
> plot(1:10, xlab = expression(NO[3]^-~(mg/L)))It's unexpected but not inexplicable. The difficulty is that the superscript begins with a unary minus operator. It _must_ have something (number or variable) after it to negate. Since the thing following the '-' is not a number, plotmath has just taken the entire following string as part of an unlikely (but technically possible) variable name "~(mg/L)". Rui Barradas' corrected form creates the '-' as a string, preventing the inappropriate mathematical interpretation. You don't actually _need_ the enclosiong {}, though;> expression(NO[3]^'-'~(mg/L))works as you intended S Ellison ******************************************************************* This email and any attachments are confidential. Any use...{{dropped:8}}