How to enlarge fonts of facet_grid ?

How could we enlarge the grid title ?
It was clear that we can enlarge the fonts of gglot title by


but how can we enlarge the text of the grid text ?
i.e Category and Type (basically making the font A,B appear 16 font
and complexity, relevance and impact in 20 font )

Similar Question:

Please find working code below:

library(ggplot2)

viz <- data.frame(type = c(rep("A",5),rep("B",4)),
                    project = c("ABC","BCD","CDE","EFG","FGI","GIK","IKL","KLM","LMO"),
                    complexity = c(.8,.95,.6,.8,.9,.3,.7,.2,.6),
                    impact = c(1,.8,.7,.8,.9,.4,.8,.6,.5),
                    relevance = c(.8,.5,.7,.9,.1,.8,.7,.7,.8))

# In order to maintain the same order after we plot
viz$type <- as.character(viz$type)
viz$type <- factor(viz$type, levels=unique(viz$type))

viz$project <- as.character(viz$project)
viz$project <- factor(viz$project, levels=unique(viz$project))

# Long version
viz_lng <- viz %>% 
  gather(-c(1,2), key = category, value = importance)

ggplot(viz_lng[which(viz_lng$importance>0),], aes(x = project, y= importance, group = 1, fill = project)) +
  geom_bar(stat="identity") + 
  facet_grid(vars(category), vars(type), scales="free_x")  +
  theme(plot.title = element_text(size = rel(5)))

Solution: strip.text

  library(ggplot2)
  
  viz <- data.frame(type = c(rep("A",5),rep("B",4)),
                    project = c("ABC","BCD","CDE","EFG","FGI","GIK","IKL","KLM","LMO"),
                    complexity = c(.8,.95,.6,.8,.9,.3,.7,.2,.6),
                    impact = c(1,.8,.7,.8,.9,.4,.8,.6,.5),
                    relevance = c(.8,.5,.7,.9,.1,.8,.7,.7,.8))
  
  viz$type <- as.character(viz$type)
  viz$type <- factor(viz$type, levels=unique(viz$type))
  
  viz$project <- as.character(viz$project)
  viz$project <- factor(viz$project, levels=unique(viz$project))
  
  viz_lng <- viz %>% 
    gather(-c(1,2), key = category, value = importance)
  
  ggplot(viz_lng[which(viz_lng$importance>0),], aes(x = project, y= importance, group = 1, fill = project)) +
    geom_bar(stat="identity") + 
    facet_grid(vars(category), vars(type), scales="free_x")  +
    theme(strip.text.x = element_text(size = 14),
          strip.text.y = element_text(size = 20))
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.