Gimelist
Gimelist

Reputation: 823

Enlarge single symbol (/) in R expression

I have the following code:

plot(x = 1, y = 1, xlim = c(1,2), ylim = c(1,2),
     ylab = expression(bgroup("(",A[B]^{C},")")[~D[2]] / bgroup("(",E[F]^{G},")")[~H]))

Which leads to this plot:

rplot

Is it possible to make the division symbol ("/") taller so it properly divides two expression and doesn't look like it's shooting out of D2?

My attempt at manually drawing it with cex>1 lead to an ugly and fat division symbol. I don't want it fatter, just taller.

I am looking for solutions that use base plot methods.

Upvotes: 4

Views: 1026

Answers (1)

dww
dww

Reputation: 31452

If you don't mind using latex, you can export the plot using tickz. That will unleash the full power of latex formatting. E.g. with a standard sized division sign it looks like this:

library(devtools)
install_github('daqana/tikzDevice')
library(tikzDevice)

tikz('test.tex', width = 4, height = 3)
par(mar=c(3,6,3,3))
plot(x = 1, y = 1, 
  xlim = c(1,2), ylim = c(1,2),
  ylab = '$(A_B^C)_{D_2} / (E_F^G)_{H}$')
dev.off()

enter image description here

or if you want an even bigger division sign, you can use one of the latex codes (in ascending order of size) \big/, \Big/, \bigg/, or \Bigg/:

tikz('test.tex', width = 4, height = 3)
par(mar=c(3,6,3,3))
plot(x = 1, y = 1, 
  xlim = c(1,2), ylim = c(1,2),
  ylab = '$\\left(A_B^C\\right)_{D_2} \\bigg/  \\left(E_F^G\\right)_{H}$')
dev.off()

enter image description here

Upvotes: 3

Related Questions