I have been trying to plot in ggplot2. On x-axis, I have factors. On y-axis, I have values that are either very small or very large, when I am plotting, in the middle part of the plot there is nothing. I want to squish this middle part but want to have y-axis in reverse order (100,90,80...0). I have searched and found out to squish the middle part by using a function borrowed from the Stackoverflow. The functions is:
squish_trans <- function(from, to, factor) {
trans <- function(x) {
# get indices for the relevant regions
isq <- x > from & x < to
ito <- x >= to
# apply transformation
x[isq] <- from + (x[isq] - from)/factor
x[ito] <- from + (to - from)/factor + (x[ito] - to)
return(x)
}
inv <- function(x) {
# get indices for the relevant regions
isq <- x > from & x < from + (to - from)/factor
ito <- x >= from + (to - from)/factor
# apply transformation
x[isq] <- from + (x[isq] - from) * factor
x[ito] <- to + (x[ito] - (from + (to - from)/factor))
return(x)
}
# return the transformation
return(trans_new("squished", trans, inv))
}
This function work very well, however, I want to reverse the y-axis. Not able to do it. Please help. Data looks like this:
s<-
"Groups Mean Stdev
F 99 0.414048151
F 98 0.457120465
F 92 0
F 1 0.01
J 80 1.638558759
E 88 0.681379406
M 83 0.01
M 1 0.01"
S <- read.delim(textConnection(s),header=TRUE,sep=" ",strip.white=TRUE)


facet_grid()by the bin. It creates the same visual effect.