squash/remove scale of axis y in ggplot 2

Dear all,
I need cut a piece of axis y, for showing better my results.
I tried used scale_y_continuos and breaks, but not work.
I would like the space between the values 25 and 35 to be minimal.

dat = data.frame(Method = c("A", "B", "C", "D", "A", "B", "C", "D"),
                    MSE= c(37.5, 21.8, 17.2, 18.2,38.3,20.4,19.9,19.7),
                    SD = c(0.4, 0.2, 0.2, 0.4, 0.2,0.2,0.2, 0.2),
                    grid = c("M", "M", "M", "M", "S", "S", "S", "S"))

mean1= dat[,2]
sd1 = dat1[,3]

a=ggplot(dat, aes(x= Method, y=MSE, colour= grid, group= grid))+
  geom_errorbar(aes(ymin= mean1-sd1, ymax=mean1+sd1), color="black", width=.1)+ geom_point(aes(colour = grid), show.legend = FALSE, size=2)+
  scale_color_discrete("grid")     +
  xlab("Methods")+
  ylab("MSE (mmolc dm-³)")+
  labs(title="CTC - Area 1") +
  theme_bw(base_size=15)
  
a

Using the ggbreak package:

library(ggplot2)
library(ggbreak)


dat = data.frame(Method = c("A", "B", "C", "D", "A", "B", "C", "D"),
                 MSE= c(37.5, 21.8, 17.2, 18.2,38.3,20.4,19.9,19.7),
                 SD = c(0.4, 0.2, 0.2, 0.4, 0.2,0.2,0.2, 0.2),
                 grid = c("M", "M", "M", "M", "S", "S", "S", "S"))

mean1= dat[,2]
sd1 = dat[,3]

ggplot(dat, aes(x= Method, y=MSE, colour= grid, group= grid))+
  geom_errorbar(aes(ymin= mean1-sd1, ymax=mean1+sd1), color="black", width=.1)+ geom_point(aes(colour = grid), show.legend = FALSE, size=2)+
  scale_color_discrete("grid")     +
  xlab("Methods")+
  ylab("MSE (mmolc dm-³)")+
  labs(title="CTC - Area 1") +
  theme_bw(base_size=15) +
  scale_y_break(breaks = c(25,37), scales=0.2)

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.