Given sample data and ggplot plotting code below:
df <- data.frame(Seller=c("Ad","Rt","Ra","Mo","Ao","Do"),
Avg_Cost=c(5.30,3.72,2.91,2.64,1.17,1.10), Num=c(6:1))
text <- "Real estate agents often refer to a home's curb appeal, the first impression
it makes on potential buyers. As a would-be seller, it's important to take as dispassionate
a look as possible at the outside of your home."
ggplot(df, aes(x=reorder(Seller, Num), y=Avg_Cost)) +
geom_bar(stat='identity') +
coord_flip() +
labs(
title = 'Costs of Selling a Home',
subtitle = stringr::str_wrap(text, 80)
) +
theme(
plot.title = element_text(hjust = 0.5),
plot.subtitle = element_text(hjust = 0),
plot.margin = unit(c(0.1, 0, 0, 0), "cm")
)
Result:
I attempt to slightly adjust subtitle to left direction (as the red arrow shows), the final subtitle will be relocated in the area of black rectangle.
I've tried by adjusting values of hjust
in plot.subtitle()
, but I didn't get the chance of success. How could I achieve that? Thanks.
Reference: