0

I thought this should be easy but I've been having a hard time trying to modify the title of each plot. I'm just new to R so I really don't know how to edit this.

enter image description here

As you can see in the image, all the plot labels are centered but not properly placed. Some letters were cut out of the frame. These labels are automatically generated by ggdensity() when I combine 2 columns in one plot.

bell_shape <- lapply(slash_k, function(x) ggdensity(x, c("Mean_Lesion_Height", "Mean_Max_Lesion_Length"), 
                                                    combine = TRUE,
                                                    add = "mean", 
                                                    fill = "lightblue", 
                                                    x.text.angle = 360, 
                                                    color = "darkblue"))
pen_bell_shape <- ggarrange(plotlist = bell_shape, 
                            widths = 10, 
                            heights = 10, 
                            nrow = 2, 
                            ncol = 3,
                            labels = c("3.IR20", "5.IR20", "7.IR20", "3.TN1", "5.TN1", "7.TN1"),
                            font.label = list(size = 9, color = "red"))

I really have no idea how to edit this. I hope someone can help me.

I tried

bell_shape + theme(axis.title.x.top = c(size = 1, color ="block")

But it returns NULL

1 Answers1

0

The solution to this problem is using

theme(strip.text())

This question has already been answered here:

[https://stackoverflow.com/questions/3290330/facet-label-font-size] [https://stackoverflow.com/questions/2751065/how-can-i-manipulate-the-strip-text-of-facet-grid-plots] [https://stackoverflow.com/questions/2631780/r-ggplot2-can-i-set-the-plot-title-to-wrap-around-and-shrink-the-text-to-fit-t]

This is also a good alternative

[https://stackoverflow.com/questions/2631780/r-ggplot2-can-i-set-the-plot-title-to-wrap-around-and-shrink-the-text-to-fit-t]

This can also provide insghts

[https://stackoverflow.com/questions/37089052/r-ggplot2-facet-grid-how-include-math-expressions-in-few-not-all-labels]

And here is how to change the facet labels

[https://stackoverflow.com/questions/3472980/how-to-change-facet-labels]

Documentation here

[https://rpkgs.datanovia.com/ggpubr/reference/facet.html]