I have scoured SO and other sites but cannot find a solution to my problem with my ggtitle()
. I know there are other examples out there, but I haven't been able to apply them directly to my issue successfully.
What I am trying to do is make a multi-line plot title where the first line is bold, size = 10 and then underneath that first line is a second (and potentially third), more descriptive line(s) in non-bold, size=8. The kicker is that I'm trying to make this left justified over the y-axis. This left justification is what makes this question unique because previous answers, including the one linked by a moderator, use atop()
which does not allow left justification or does not include it in the answer linked.
Here is what my plot currently looks like:
title <- paste("An analysis of the mtcars dataset ")
subheader <- paste("How does mpg change by \n number of cyl?")
ggplot(mtcars, aes(mpg,cyl))+
geom_smooth(aes(fill="Mean",level=0.095)) +
ggtitle(paste0(title,"\n",subheader)) +
scale_fill_grey(name='95% Confidence\n Interval',start=.65,end=.65) +
theme(plot.title = element_text(size = rel(2.0),hjust=-.1,face="bold"))
I have tried using bquote()
, mtext()
, atop()
, and even a grungy paste()
with extra spaces included to push the title....but I haven't been able to find a solution.
Please, let me know if you have any questions or need any clarification. I appreciate any and all help!