GGplot custom scale transformation with custom ticks

☆樱花仙子☆ 提交于 2019-11-28 14:14:41
Mark Peterson

You may need to set the scale on the y axis directly:

ggplot(dat, aes(x=time.tot, y=error, color=type)) +
  geom_line() + geom_point() + coord_trans(y = tn)
  + scale_y_continuous(breaks = c(0,0.1,1))

Also, the non-straight lines are the expected behavior of coord_trans. from the help: "coord_trans is different to scale transformations in that it occurs after statistical transformation and will affect the visual appearance of geoms - there is no guarantee that straight lines will continue to be straight."

Instead, try:

b <- 10^-c(Inf, 8:0)
ggplot(dat, aes(x=time.tot, y=error, color=type)) +
  geom_line() + geom_point() + scale_y_continuous(breaks = b, labels=b, trans = tn)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!