ORBITTING ARYABHATA
ORBITTING ARYABHATA

Reputation: 37

How to change the font style and size of text within ggpairs correlation plot

I have plotted a correlation matrix and I am unable to increase the font size and make it bold for the text and values appearing within the plot. I have used the following code:

library(GGally)

# Create the ggpairs plot
Output <- ggpairs(Combined_with_MFV, 
                  columns = 2:15, 
                  aes(colour=Genotype),
                  lower = list(continuous = "smooth"),
                  upper = list(continuous = wrap("cor", method = "pearson")))

# Customize the appearance of the plot to make axis labels bold and change font size
Output <- Output + 
  theme(
    axis.text.x = element_text(face = "bold", size = 12), 
    axis.text.y = element_text(face = "bold", size = 12), 
    text = element_text(size = 16, family = "bold"))

tiff('Morpho.tiff', units="in", width=25, height=16, res=600, compression = 'lzw')
Output
dev.off()
getwd()

But I want to increase the size of the text as indicated in the attached picture.

enter image description here

Upvotes: 0

Views: 259

Answers (1)

George Savva
George Savva

Reputation: 5326

You can add the font size and face to wrap. So for a toy example:

dat1 <- data.frame(x=rnorm(100), y=rnorm(100), genotype=sample(c("A","B"),100,TRUE))

ggpairs(dat1,columns=1:2 , aes(color=genotype),
        upper=list(continuous=wrap("cor", method="pearson",size=10, fontface="bold")))

enter image description here

Upvotes: 3

Related Questions