Can't set limits with coord_trans

后端 未结 2 805
一生所求
一生所求 2021-01-11 20:21

I have some data that show a geometric relationship, but have outliers. For example:

x = seq(0.1, 1, 0.01)
dat = data.frame(x=x, y=10^x)
dat[50:60, 2] = 10

         


        
2条回答
  •  伪装坚强ぢ
    2021-01-11 21:06

    I had the same issue and struggled to solve it until looking more closely at ?coord_trans (in v1.0.0 of ggplot2):

    Usage

    coord_trans(xtrans = "identity", ytrans = "identity", limx = NULL, limy = NULL)

    So you can set the transformations and the limits at the same time, like this:

    ggplot(dat, aes(x=x, y=y)) + geom_line() +
      coord_trans(ytrans="log10", limy=c(2,8))
    

提交回复
热议问题