This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to reverse the color scale of a dot plot made by ggplot2?

Hi all,

I want to reverse the color scale of my dot plot below - the higher 'NES' score is darker, the lower 'NES' score is brighter. Could you help me with this issue?

enter image description here

Thanks in advance!

Joshua

library(ggplot2)
library(forcats)

data <-read.csv("C:/.../Dot plot.csv", fileEncoding = 'UTF-8-BOM')

Fig <- ggplot(data,aes(x = Groups, y = reorder(Pathways, +Order), size = nlogFDR, color = NES)) + 
geom_point(alpha = 0.8) +
scale_size(range = c(3, 13), name="-log10(FDR)") +
guides(color = guide_colorbar(reverse = FALSE)) +
theme_classic()

Fig
dot ggplot2 color plot scale

try adding scale_color_continuous(trans='reverse') after geom_point and before scale_size

0 answers

No answers yet.

Log in to answer this question.