I am plotting the Year over Year (YoY) Percentage Change in GDP for a country and would like to have the negative YoY values be highlighted as "RED" text in callout boxes on the graph.
I have created a graph and added the callouts for the values using "geom_label". I want to change the negative values in the geom_label callouts to "RED" text, while keeping the positive values in the geom_label callouts as "BLACK" text. Please see the code below:
ggplot(data = gdp_line) +
aes(x = Year, y = YoY * 100, group = 1) +
geom_line(colour = "blue") +
labs(y = "GDP YoY % Change", x = "") +
ggtitle("GDP YoY % Change (at Constant Prices: 2007 as Base Year)") +
**Creation of Callout Text Boxes with YoY % Change Values**
**I want to make the negative YoY % Change Values "RED" text**
**I want to keep the positive YoY values as "BLACK" text**
geom_label(aes(label = round(YoY * 100, digits = 2)), size = 2.5, fontface = "bold") +
scale_y_continuous(labels = function(x) paste0(x,"%")) +
labs(caption = "Source: STATIN Jamaica")