Is it possible to insert the legend of a ggplot::geom_area() into the respective areas?
I.e., I would like to change
to:
(source for the plot: https://www.geeksforgeeks.org/stacked-area-chart-with-r/)
Is it possible to insert the legend of a ggplot::geom_area() into the respective areas?
I.e., I would like to change
to:
(source for the plot: https://www.geeksforgeeks.org/stacked-area-chart-with-r/)
Copyright © 2021 Jogjafile Inc.


You can use
geom_textwithposition_fill. You will also need to filter to include only a single year of your choosing:Data used
We would normally ask that questions contain the necessary data and code directly rather than pointing to external links. External links may change, and there have been instances of spammy or malicious links. I have harvested the relevant code from the link provided for others to reproduce the plot here: