I am actually trying to build a graph showing the fiscal space of a country, so that it looks like But for now it looks like
I don't know how to add the transparent triangle like in the model. I tried with several functions but I didn't manage to succeed.
I used:
geom_area(x = c(-15, 15, 15), c(-15, -15, 15))
geom_polygon(aes(x = c(-15, 15, 15),y = c(-15, -15, 15), col = 'grey'))
as well as
triangle <- tibble(x = -15:15)
geom_ribbon(data = triangle, aes(x, x, ymin=-15, ymax=15), alpha = 0.4)
But none of these functions worked. Here is a preview of my code:
df %>%
ggplot(aes(CAB, gvtbal, xmin=-15, xmax=15, ymin=-15, ymax=15, colour=year)) +
geom_point() +
geom_label_repel(aes(label= year),
box.padding = 0.35,
point.padding = 0.5,
segment.color = 'grey50',
max.overlaps = 50,
force= 85) +
# Add lines 45° line for private sector, add x and y axis for CAB and gvtbal
geom_abline(color='grey') +
geom_vline(xintercept = 0, color='grey')+
geom_hline(yintercept = 0, color='grey')
I would like the shaded triangle to cover the area below the geom_abline
function.
Thank you.