我有一个 3 列矩阵;绘图由基于第 1 列和第 2 列值的点绘制,但基于第 2 列(6 个不同组)着色。我可以成功绘制所有点,但是,分配了紫色的最后一个绘图组(组 6)掩盖了其他组的绘图。有没有办法让情节更加透明?
s <- read.table("/.../parse-output.txt", sep="\t")
dim(s)
[1] 67124 3
x <- s[,1]
y <- s[,2]
z <- s[,3]
cols <- cut(z, 6, labels = c("pink", "red", "yellow", "blue", "green", "purple"))
plot(x, y, main= "Fragment recruitment plot - FR-HIT", ylab = "Percent identity", xlab = "Base pair position", col = as.character(cols), pch=16)
最佳答案
否则,您可以在 scales
包中使用函数 alpha
,您可以在其中直接输入颜色向量(即使它们是示例中的因子):
library(scales)
cols <- cut(z, 6, labels = c("pink", "red", "yellow", "blue", "green", "purple"))
plot(x, y, main= "Fragment recruitment plot - FR-HIT",
ylab = "Percent identity", xlab = "Base pair position",
col = alpha(cols, 0.4), pch=16)
# For an alpha of 0.4, i. e. an opacity of 40%.
关于r - 有什么方法可以使 R 中散点图中的绘图点更加透明吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12995683/