我对使用ggplot2包创建的绘图有疑问。假设我们有这样的情节:
df = data.frame(
numbers = seq(1,5),
labels = c(
"Brand",
"Good Brand",
"The Best Brand",
"The Best Brand Today",
"The Best Brand This Month"
)
)
df = df[order(-df$numbers),]
plot = ggplot(data = df, aes(x=labels, y=numbers))+
geom_bar(stat="identity", fill='orange')+
coord_flip()+
labs(
title = "Exemplary title",
caption = "Exemplary caption 1\nExemplary caption number 2"
)+
theme(
plot.title = element_text(hjust = -0.5),
plot.caption = element_text(hjust = -0.5),
panel.spacing = unit(c(0,0,0,20), "cm")
)
plot
我的情况如下:
vjust
和title
设置负caption
值并不是最佳解决方案,原因有两个:
\n
字符,则格式非常奇怪,似乎依赖于字幕长度,有没有更好的方法将标题和标题对齐到绘图的左侧(所以在这种情况下是整个图片的左侧)?
x= reorder(labels, numbers)
更好地解决吗?