点击蓝字↑↑↑“微生态”,轻松关注不迷路
本文由阿童木根据实践经验而整理,希望对大家有帮助。
原创微文,欢迎转发转载。
举例展示几种常用的ggplot取色方法,例如:
1. 通过字符串区分取色;
2. 通过数字取色;
3. 取渐变色;
4. 通过RColotBrewer方案取色。
一, 输入数据
library(ggplot2)
library(RColorBrewer)
df = data.frame(x=1:10, y=seq(1, 20, 2), z=seq(1000, 100, -100), c=paste("color", seq(1, 10, 1)))