其他分享
首页 > 其他分享> > ggplot2: display every nth value on discrete axis

ggplot2: display every nth value on discrete axis

作者:互联网

every_nth = function(n) {
return(function(x) {x[c(TRUE, rep(FALSE, n - 1))]})
}

ggplot(mpg, aes(x = class, y = cyl)) +
geom_point() +
scale_x_discrete(breaks = every_nth(n = 3))

https://stackoverflow.com/questions/52919899/ggplot2-display-every-nth-value-on-discrete-axis

标签:function,discrete,value,nth,every,ggplot2,axis
来源: https://www.cnblogs.com/3Dgenome/p/14742468.html