ggobi / ggally

R package that extends ggplot2
http://ggobi.github.io/ggally/
588 stars 118 forks source link

Adding math symbols to ggally_or #394

Open shbrainard opened 3 years ago

shbrainard commented 3 years ago

Is it possible to change the default "Corr" text to a mathematical symbol? I tried an approach that works for ggplot axis titles, but mathematical formatting was not retained:

txt <- as.expression(bquote(r^2))
gg.shoulder <- ggpairs(data =corr.data, 
             upper = list(continuous = wrap(ggally_cor, size = 8, title = txt)), 
             lower = list(continuous = 'smooth')) +
             theme_few(base_size = 26) + theme(panel.spacing = unit(0.1, "lines"))

Thanks!

schloerke commented 3 years ago

I would have believed that the fix would have been to add parse = TRUE as an argument to pass through to geom_text().

However, it does not work as the correlations can not not be parsed.

Error in parse(text = text[[i]]) : <text>:2:8: unexpected '*'
1: r^2:
2: 0.872***

This would be really neat to have work. The fix will be to try and separate the two display lines.

I don't know how that will work yet. We may have to print "title + k empty blank lines" and "1 blank line + k correlation lines". This would fail if the title had a "\n"

psadil commented 8 months ago

What about leveraging something from ggtext, like geom_richtext?