how do I add a 3rd axis to a ggplot?

the recommended resource to learn how to use ggplot is https://r4ds.had.co.nz/data-visualisation.html

If you have a partial solution that you want to add an element to , then consider making a reprex that you share.
FAQ: How to do a minimal reproducible example ( reprex ) for beginners