I have a problem with ggplot
title positioning. When I use hjust
argument to slide title a bit right, both lines undesirably slide left and right. I want them one under the other. drawlabel()
,annototations
are not useful for my case, because they depend on x and y axis and their units(date,currency,kg) which mean every time I have to adjust them. I want unique coordinate system, whatever I am plotting I can easily use same place for different plots.
An undesired example with code is shown below.
set.seed(10)
df <- data.frame(x=1:10,y=round(rnorm(10)*1:10,2))
ggplot(df,aes(x=x,y=y))+
geom_line(size=0.75)+
labs(title = 'Here comes my title like that some words\nand my second line title')+
theme(
plot.title.position = 'plot',
plot.title = element_text(hjust = 0.075)
)
Undesirable plot
Desirable plot