0

How do I plot the taxa in this data so that they are ordered by their depth distributions? For example, I want the taxa that only occur in one or two depths at the top and the taxa that have wider depth distributions and occur in more depth zones at the bottom. This is the code I have so far.

ggplot(df) + 
geom_point(mapping = aes(x = DepthInMeters, 
                         y = ScientificName), 
           size = 1, 
           shape = 12, 
           colour = "blue") + 
theme(axis.text.y = element_text(color = "grey20")) 

enter image description here

neilfws
  • 32,751
  • 5
  • 50
  • 63
Gina
  • 57
  • 6
  • `ScientificName`is a character, so your y axis is ordered correctly, though not as you want it to be. Create a factor or a numeric variable that orders the taxa as you wish, and then plot that. Sample datra would be helpful. – Limey Jun 06 '22 at 06:47
  • can you give an example of how to do this please? – Gina Jun 06 '22 at 20:32
  • Does this answer your question? [Order discrete x scale by frequency/value](https://stackoverflow.com/questions/3253641/order-discrete-x-scale-by-frequency-value) – Limey Jun 06 '22 at 21:25

0 Answers0