gforge / Gmisc

An R package for creating tables, some plots and other useful utilities too small to merit their own package
49 stars 14 forks source link

Update R/boxGrobs.R #40

Closed aghaynes closed 5 years ago

aghaynes commented 6 years ago

add expression as allowable label class. textGrob supports expressions, which in turn support bold/italics and all sorts of other wonderful things.

gforge commented 6 years ago

Awesome! Could you add some examples, preferably somewhere in the vignette? Using expressions isn't that straightforward to most.

Also I tried to run the following:

boxGrob(expression(plain(sin) * phi, "  and  ", plain(cos) * phi), 
        width=.8, height=.8, 
        x=0, y=0, 
        bjust = c(0,0),
        txt_gp = gpar(col="darkblue", cex=2),
        box_gp = gpar(fill="lightyellow", col="darkblue"))

and it would only print the first section of the expression - this seems built-in to the underlying grid.text but it's a little annoying...

gforge commented 6 years ago

Sorry, found it, all it needed was some paste:

boxGrob(expression(paste(plain(sin) * phi, "  and  ",
                         plain(cos) * phi)), 
        width=.8, height=.8, 
        x=0, y=0, 
        bjust = c(0,0),
        txt_gp = gpar(col="darkblue", cex=2),
        box_gp = gpar(fill="lightyellow", col="darkblue"))

Still, we need to add some guidance to to the end-user. Do you mind doing that?

aghaynes commented 5 years ago

Done! :)

gforge commented 5 years ago

Thanks!