squash_axis | R Documentation |
This function was transcribed from the post on Stackoverflow. –> https: //stackoverflow.com/questions/61010786/error-nas-are-not-allowed-in-subscripted-assignments-while-using-squash-axis-i
squash_axis(from, to, magnif_ratio)
from |
a double value, left (bottom) end of the axis |
to |
a double value, right (top) end of the axis |
magnif_ratio |
the compression scale factor of the range between from and to. |
A transformation called "squash_axis", which is capsulated by trans_new() function
trans_new
if(interactive()){
library(ggplot2)
library(frabento)
set.seed(123)
dat <- data.frame(group = rep(c('A', 'B', 'C', 'D'), each = 10),
value = c(rnorm(10), rnorm(10) + 100))
ggplot(dat,aes(x = group, y = value)) +
geom_point() +
coord_trans(y = squash_axis(5, 95, 10))
ggplot(dat,aes(x = group,y = value)) +
geom_point() +
scale_y_continuous(trans = squash_axis(5, 95, 10))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.