How to reverse the color scale of a dot plot made by ggplot2?
0
1
Entering edit mode
3.1 years ago
vHelmholtz ▴ 40

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 • 4.6k views
ADD COMMENT
2
Entering edit mode

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

ADD REPLY
0
Entering edit mode

That works! Thank you!

-Joshua

ADD REPLY

Login before adding your answer.

Traffic: 2728 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6