Spacing around \cdot (%.%) unequal in pdf

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Spacing around \cdot (%.%) unequal in pdf

Pascal.Niklaus
I am struggling labeling an axis in a plot.

Here is a minimal example illustrating the point:


pdf("mve.pdf",width=5,height=5)
ypos <- c(1:3) * 1e6
ylabs <- sapply(ypos/1e6, function(i) as.expression(bquote(.(i)%.%10^6)))
plot(rep(1,3), ypos, yaxt="n", ylab="")
axis(2, at=ypos, labels=ylabs, las=1)
dev.off()


First, I find the space left and right of the \cdot operator rather
larger. Is there a way to decrease it?

Second, and more important, in the generated PDF, the space left of the
dot is much bigger, it looks as if it was typeset as e.g. "3 *10^6".

Thanks for any hint

Pascal

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Spacing around \cdot (%.%) unequal in pdf

Martin Maechler
>>>>> Pascal A Niklaus
>>>>>     on Wed, 6 Feb 2019 19:48:49 +0100 writes:

    > I am struggling labeling an axis in a plot.
    > Here is a minimal example illustrating the point:


    > pdf("mve.pdf",width=5,height=5)
    > ypos <- c(1:3) * 1e6
    > ylabs <- sapply(ypos/1e6, function(i) as.expression(bquote(.(i)%.%10^6)))
    > plot(rep(1,3), ypos, yaxt="n", ylab="")
    > axis(2, at=ypos, labels=ylabs, las=1)
    > dev.off()


    > First, I find the space left and right of the \cdot operator rather
    > larger. Is there a way to decrease it?

    > Second, and more important, in the generated PDF, the space left of the
    > dot is much bigger, it looks as if it was typeset as e.g. "3 *10^6".

Vaguely related:   I have advertized my  eaxis()  and
pretty10exp() functions in package 'sfsmisc' for doing what you do above more
generally and automatically:

if(!require("sfsmisc")) {
  install.packages("sfsmisc") ; library("sfsmisc")
}

ypos <- c(1:3) * 1e6
plot(rep(1,3), ypos, yaxt="n", ylab="")
## e.g.,
eaxis(2, at = ypos, labels = pretty10exp(ypos, drop.1=TRUE))

gives a nice plot for me, not using 'cdot' but rather

  > pretty10exp(ypos, drop.1=TRUE)
  expression(10^6, 2 %*% 10^6, 3 %*% 10^6)
  >

    > Thanks for any hint
    > Pascal

You are welcome!

Martin Maechler
ETH Zurich and R Core Team

______________________________________________
[hidden email] 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.