想要学习R数据可视化,小果带你见识ggplot2之标度(七)
1.分箱渐变色
> p1 <- ggplot(df, aes(x, y)) +
+ geom_point(aes(colour = z1))
> p2 <- ggplot(df, aes(x, y)) +
+ geom_point(aes(colour = z1)) +
+ scale_colour_steps(low = "skyblue", high = "purple")
> p3 <- ggplot(df, aes(x, y)) +
+ geom_point(aes(colour = z1)) +
+ scale_colour_steps2()
> p4 <- ggplot(df, aes(x, y)) +
+ geom_point(aes(colour = z1)) +
+ scale_colour_stepsn(colours = terrain.colors(10))
> plot_grid(p1, p2, p3, p4, labels = LETTERS[1:4], nrow = 2)
2.色轮颜色
> dsamp <- diamonds[sample(nrow(diamonds), 2000), ]
> d <- ggplot(dsamp, aes(carat, price)) +
+ geom_point(aes(colour = clarity))
> p1<- d + scale_colour_hue()
> p2 <- d + scale_colour_hue("xiaoguo")
> p3 <- d + scale_colour_hue(expression(clarity[beta]))
> d + scale_colour_hue(l = 80, c = 60)
> plot_grid(d, p1, p2, p3, labels = LETTERS[1:4], nrow = 2)
> p1 <- d + scale_colour_hue(l = 30, c = 60)
> p2 <- d + scale_colour_hue(l = 80, c = 60)
> p3 <- d + scale_colour_hue(l = 80, c = 160)
> p4 <- d + scale_colour_hue(l = 100, c = 160)
> plot_grid(p1, p2, p3, p4, labels = LETTERS[1:4], nrow = 2)
> p1 <- d + scale_colour_hue(h = c(0, 90))
> p2 <- d + scale_colour_hue(h = c(90, 180))
> p3 <- d + scale_colour_hue(h = c(180, 270))
> p4 <- d + scale_colour_hue(h = c(270, 360))
> plot_grid(p1, p2, p3, p4, labels = LETTERS[1:4], nrow = 2)
> d <- ggplot(dsamp, aes(carat, price, colour = clarity))
> p2 <- d + geom_point(alpha = 0.2)
> p3 <- d + geom_point(alpha = 0.6)
> p4 <- d + geom_point(alpha = 0.9)
> plot_grid(p2, p3, p4, labels = LETTERS[1:4], nrow = 2)
小伙伴们今天是否收获颇多呢,小果今天就先讲到这里啦,关于配色的内容小果会在后续文章中继续讲述,小伙伴们记得及时关注小果的文章哦,还有一定记得要关注小果的工具平台呀(http://www.biocloudservice.com/home.html),
那今天小果的分享就到这里啦,再会啦。
小果还提供思路设计、定制生信分析、文献思路复现;有需要的小伙伴欢迎直接扫码咨询小果,竭诚为您的科研助力!
定制生信分析
服务器租赁
扫码咨询小果
往期回顾
01 |
02 |
03 |
04 |