【发布时间】:2020-02-28 16:43:55
【问题描述】:
我正在 ggplot 中为我的情节添加标题,没有问题。我可以改变位置和单一的颜色和文字。
我想做的是添加一个包含多个文本的标题,每个文本(单词)都是一个单独的颜色。
library(ggplot2)
ggplot(xdata, aes(x = Days, y= maxGenOutletTemp)) +
geom_point(shape = 18, color = "#8181F7")+
geom_hline(yintercept = `1yrWTGbase`$Gen.Cool.1YRBase, linetype="solid", color = "#04B431", size = 1)+
geom_smooth(method = lm, linetype = "dashed", color = "red", fullrange = TRUE)+
geom_smooth(method = "auto",se = F)+
scale_x_datetime(date_breaks = "1 week", date_minor_breaks = "1 day",
date_labels = "%m/%d")+
scale_y_continuous(limits=c(min(xdata$maxGenOutletTemp), 85))+
theme_light()+
labs(title = "WTG Generator Coolant.Outlet last 90 days vs 1yr Wtg.Baseline",
subtitle = "Last 90 Days",
caption = "Green.Line -> 1yr WTG.baseline // Red.Line -> Trend line // Blue.Line -> Daily Moving Trend")+
theme(
plot.title = element_text(hjust = 0.5, size = 14), # Center title position and size
plot.subtitle = element_text(hjust = 0.5), # Center subtitle
plot.caption = element_text(hjust = 0, face = "bold"), # move caption to the left
)
我想要一个标题如下:
1yr WTG.baseline(绿色文字),趋势线(红色文字),每日移动趋势(蓝色文字)
【问题讨论】: