问题描述
这太容易了,但是如何在ggplot上获得标题?
ggplot(df,aes(x = month,y = value)) +
geom_area(aes(color = variable,fill = variable),alpha = 0.5,position = position_dodge(0.8)) +
scale_color_manual(values = c("#00AFBB","#E7B800")) +
scale_fill_manual(values = c("#00AFBB","#E7B800"))
解决方法
肯定已经问过了……但是至少很容易回答。您有两个简单的选择:
plot + labs(title="Your Title Here")
或:
plot + ggtitle("Your Title Here")
请注意,第一种使用labs()
的方法允许您访问绘图中的许多相关文本,在代码段中总结如下:
plot + labs(
title="Plot Title",subtitle="Plot Subtitle",caption="Plot caption",x="X axis title",y="Y axis title",color="Legend Title for color",fill="Legend Title for fill",...)