drieslab / Giotto

Spatial omics analysis toolbox
https://drieslab.github.io/Giotto_website/
Other
257 stars 98 forks source link

plot legend order #237

Open joe-jhou2 opened 2 years ago

joe-jhou2 commented 2 years ago

Does any parameter control legend order? When showing clusters, the legend order is so random, can be 1 3 2 7 4 6 5. I cannot get why it happens and how to organize it.

RubD commented 2 years ago

If the plot is a ggplot object, which is true for most 2D plots, then the ggplot object can be returned and updated using ggplot language. In that case you need to set return_plot = TRUE and save the plot to a variable, like for example myplot <- spatPlot2D. Ggplot offers ways to control legend order etc. However, in my opinion, it's typically easier (and faster) to do this outside of R.