I am sure it is easy to solve this question.
I am trying to fill the area below the line I plot from "mydata" using ggplot2
.
here the example:
a = seq(10, 100, 5)
b = -(runif(19, 0, 50))
mydata <- data.frame(a, b)
ggplot(data = mydata, aes(x = a, y = b)) +
geom_area()
geom_bar
fills above the line, considering the area the one from 0 and the values (negative). I want to fill the other area and I think I should delimit the area I want to colour, but I do not know how.
The script above is just an easy example. My real script is
ggplot(data = ctd, aes(x = Longitude, y = Depth)) +
geom_raster(aes(fill = NO3_uM)) +
scale_fill_gradientn(colours = rev(my_colours)) +
geom_contour(aes(z = NO3_uM), binwidth = 2, colour = "black", alpha = 0.2) +
#geom_contour(aes(z = NO3_uM), breaks = 20, colour = "black") +
geom_point(data = ctd, aes(x = Longitude, y = Depth),
colour = 'black', size = 3, alpha = 1, shape = 15) +
geom_area(data = trsect, aes(x = Longitude, y = Depth), fill = "black")+
ylim(-320,0)
my result is:
I want to colour the other area of the "mountain"