I would like to plot my data, highlighting the positive and negative values ("firebrick" and "dodgerblue4"respectively) and create a legend with 'Upwelling' being the positive values and "Downwelling" the negative values. My code now looks like this:
ggplot(dados19,aes(Date,UI))+
geom_line()+
ggtitle("Upwelling Index during the period 2012-2019")+
theme(plot.title = element_text(hjust = 0.5))+
xlab("Year") + ylab("Upwelling index")
A tibble: 10,225 x 2
UI Date
<dbl> <dttm>
37.9 2012-01-01 00:00:00
9.18 2012-01-01 06:00:00
1.18 2012-01-01 12:00:00
27.0 2012-01-01 18:00:00
-292. 2012-01-02 00:00:00
98.2 2012-01-02 06:00:00
95.9 2012-01-02 12:00:00
6.19 2012-01-02 18:00:00
-4.65 2012-01-03 00:00:00
40.1 2012-01-03 06:00:00
# ... With 10,215 more rows
The best way to represented was using gradient
scale_color_gradient(low = "dodgerblue4",high = "firebrick")+
And the plot was like this:
I need the same plot but with only the 2 colors (red for positive values and blue for negative values), not a gradient.