After rotating boxplot x-axis labels 45 degrees, as suggested by @dunnpa, some right side labels are truncated by default right margin. To include all x-axis labels in the plot, the right margin is set with the following procedure. However, this procedure needs to be optimized for the following two purposes:
Guarantee that all x-axis labels are included and not truncated.
Guarantee that right margin always extend the rightmost label by 5.5 points, which is the default ggplot2 margin.
After rotating boxplot x-axis labels 45 degrees, as suggested by @dunnpa, some right side labels are truncated by default right margin. To include all x-axis labels in the plot, the right margin is set with the following procedure. However, this procedure needs to be optimized for the following two purposes:
https://github.com/PediatricOpenTargets/OpenPedCan-api/blob/b265d7b74028c5d2dc126cea69cf043fe740ad7d/src/get_gene_tpm_boxplot.R#L75-L87
Example boxplot with truncated x-axis labels: