Reputation: 1151
I have this data like this
z <- structure(list(Description = c("Neurotransmitter receptors and postsynaptic signal transmission",
"Muscle contraction", "Class A/1 (Rhodopsin-like receptors)",
"Signaling by Rho GTPases", "Metabolism of carbohydrates", "Extracellular matrix organization",
"Transmission across Chemical Synapses", "G alpha (i) signalling events",
"GPCR ligand binding", "Neuronal System"), p.adjust = c(0.563732077253957,
0.563732077253957, 0.774251160588198, 0.797669099976286, 0.655931854998983,
0.655931854998983, 0.563732077253957, 0.774251160588198, 0.774251160588198,
0.655931854998983), Count = c(9L, 9L, 9L, 9L, 10L, 10L, 11L,
11L, 12L, 13L)), row.names = c("R-HSA-112314", "R-HSA-397014",
"R-HSA-373076", "R-HSA-194315", "R-HSA-71387", "R-HSA-1474244",
"R-HSA-112315", "R-HSA-418594", "R-HSA-500792", "R-HSA-112316"
), class = "data.frame")
I would like to plot labels of y axis based on values of x axis, so from the smallest one to the largest one. Now it plots me in alphabetic order. How to do this?
ggplot(z, aes(Count, Description, size=Count, color=p.adjust))+
geom_point()
Somethine like this
Upvotes: 1
Views: 31
Reputation: 12719
With forcats::fct_reorder(Description, Count)
you can change the order of y values.
library(ggplot2)
library(forcats)
ggplot(z, aes(Count, fct_reorder(Description, Count), size=Count, color=p.adjust))+
geom_point()
Created on 2022-02-01 by the reprex package (v2.0.1)
Upvotes: 1